[MIG] product_contract: Migration to 16.0

This commit is contained in:
Rad0van
2023-06-08 18:22:40 +02:00
committed by Abraham Anes
parent fe8ed89bc6
commit 1b930d402e
10 changed files with 94 additions and 69 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"))