[IMP] uom: add constraints to force reference factor
When importing big amount of data, user can import a list of uom. There is no constraint in Odoo to force the factor to be equal to 1.0 for the reference UoM in a category. Onchange is not enought to ensure that constraint, so this commit adds one in SQL for data intergrity and to avoid problem in '_compute_quantity' method.
This commit is contained in:
@@ -59,7 +59,8 @@ class UoM(models.Model):
|
||||
|
||||
_sql_constraints = [
|
||||
('factor_gt_zero', 'CHECK (factor!=0)', 'The conversion ratio for a unit of measure cannot be 0!'),
|
||||
('rounding_gt_zero', 'CHECK (rounding>0)', 'The rounding precision must be strictly positive.')
|
||||
('rounding_gt_zero', 'CHECK (rounding>0)', 'The rounding precision must be strictly positive.'),
|
||||
('factor_reference_is_one', "CHECK((uom_type = 'reference' AND factor = 1.0) OR (uom_type != 'reference'))", "The reference unit must have a conversion factor equal to 1.")
|
||||
]
|
||||
|
||||
@api.one
|
||||
|
||||
Reference in New Issue
Block a user