From 90aca03a1ff602c2f6d2de18ea5cca828e087b7c Mon Sep 17 00:00:00 2001 From: sergiocorato Date: Tue, 18 Jun 2024 10:45:19 +0200 Subject: [PATCH] [14.0][FIX] product_contract recordset in constrains --- product_contract/models/product_template.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/product_contract/models/product_template.py b/product_contract/models/product_template.py index 12bbeda64f..c0da947c71 100644 --- a/product_contract/models/product_template.py +++ b/product_contract/models/product_template.py @@ -73,7 +73,13 @@ def write(self, vals): @api.constrains("is_contract", "type") def _check_contract_product_type(self): """ - Contract product should be service type + Contract product should be service type, check by recordset """ - if self.is_contract and self.type != "service": - raise ValidationError(_("Contract product should be service type")) + for record in self: + if record.is_contract and record.type != "service": + raise ValidationError( + _( + "Contract product (%(product_name)s) should be service type", + product_name=record.name, + ) + )