Add constraint
This commit is contained in:
parent
705537a330
commit
bc3862bd50
1 changed files with 8 additions and 1 deletions
|
|
@ -1,4 +1,5 @@
|
|||
from odoo import models, fields
|
||||
from odoo import models, fields, api
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class SaleOrderLine(models.Model):
|
||||
|
|
@ -6,3 +7,9 @@ class SaleOrderLine(models.Model):
|
|||
|
||||
product_uom_min_qty = fields.Float(string="Min qty.", digits="Product Unit of Measure")
|
||||
product_uom_max_qty = fields.Float(string="Max qty.", digits="Product Unit of Measure")
|
||||
|
||||
@api.constrains("product_uom_qty")
|
||||
def _check_product_uom_qty(self):
|
||||
for record in self:
|
||||
if record.product_uom_qty > record.product_uom_max_qty:
|
||||
raise ValidationError("The quantity must be less than or equal to the maximum quantity.")
|
||||
|
|
|
|||
Loading…
Reference in a new issue