requested constraints
parent
d051740a
No related branches found
No related tags found
This commit is part of merge request !1. Comments created here will be created in the context of that merge request.
from odoo import fields, models | ||
from odoo import api, exceptions, fields, models | ||
from odoo.addons import decimal_precision as dp | ||
... | ... | @@ -8,3 +8,11 @@ class CitruxWarehouseLocation(models.Model): |
latitude = fields.Float("Latitude", digits=dp.get_precision("Stock Location")) | ||
longitude = fields.Float("Longitude", digits=dp.get_precision("Stock Location")) | ||
@api.constrains("latitude", "longitude") | ||
def _check_for_valid_coordinates(self): | ||
if not -90 >= self.latitude <= 90: | ||
raise exceptions.ValidationError("Latitude value must be between -90 and 90") | ||
|
||
if not -180 >= self.longitude <= 180: | ||
raise exceptions.ValidationError("Longitude value must be between -180 and 180") |