[MIG] product_contract: Migration to 16.0

This commit is contained in:
Rad0van
2023-06-08 18:22:40 +02:00
parent b3f1fa3a39
commit a41cafe605
11 changed files with 109 additions and 90 deletions

View File

@@ -68,12 +68,12 @@ class ProductTemplate(models.Model):
self.with_company(company).write(
{"property_contract_template_id": False}
)
super().write(vals)
return super().write(vals)
@api.constrains("is_contract", "type")
def _check_contract_product_type(self):
"""
Contract product should be service type
"""
if self.is_contract and self.type != "service":
if any([product.is_contract and product.type != "service" for product in self]):
raise ValidationError(_("Contract product should be service type"))