Skip to content
Snippets Groups Projects
Commit 2734373c authored by ebuzeyTra's avatar ebuzeyTra
Browse files

Constraint separated to improve the performance

parent 85f856fa
No related branches found
No related tags found
2 merge requests!195[REL] 14.0.2.0.0,!181Feature/add constrain to spa
from odoo import fields, models, api
from odoo import fields, models, api, _
from odoo.exceptions import ValidationError
......@@ -51,7 +51,13 @@ class SupplyPointAssignation(models.Model):
def constraint_coefficient(self):
for record in self:
if record.coefficient < 0:
raise ValidationError("Coefficient can't be negative.")
raise ValidationError(_("Coefficient can't be negative."))
@api.constrains("owner_id")
def constraint_coefficient(self):
for record in self:
if record.owner_id and not record.owner_id.member:
raise ValidationError(_("The selected partner is not a member"))
@api.onchange('coefficient')
def _onchange_coefficient(self):
......
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