Skip to content
Snippets Groups Projects
Commit 5f6b88d2 authored by Jose Luis Zanotti's avatar Jose Luis Zanotti
Browse files

requested constraints

parent d051740a
No related branches found
No related tags found
1 merge request!1Resolve CIT-2 "12.0 create lat long"
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")
  • Contributor

    en estos casos es donde deberías usar el _() para q el mensaje salga traducido

  • Jose Luis Zanotti @samsagaz

    changed this line in version 7 of the diff

    ·

    changed this line in version 7 of the diff

    Toggle commit list
  • Please register or sign in to reply
if not -180 >= self.longitude <= 180:
raise exceptions.ValidationError("Longitude value must be between -180 and 180")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment