From c079ae699093c10ca1d232445a16dcb56b6b635a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A0n=20Todorovich?= Date: Tue, 25 Oct 2022 16:41:38 -0300 Subject: [PATCH] [FIX] mrp_bom_attribute_match: write products recordset The check expects a single record, so it should be processed accordingly. --- mrp_bom_attribute_match/models/product.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mrp_bom_attribute_match/models/product.py b/mrp_bom_attribute_match/models/product.py index 806af87dd..ec4a9062d 100644 --- a/mrp_bom_attribute_match/models/product.py +++ b/mrp_bom_attribute_match/models/product.py @@ -6,13 +6,14 @@ class ProductTemplate(models.Model): _inherit = "product.template" def write(self, vals): - res = super(ProductTemplate, self).write(vals) - for product in self: - product.check_product_with_component_change_allowed() - product.check_component_change_allowed() + res = super().write(vals) + for rec in self: + rec.check_product_with_component_change_allowed() + rec.check_component_change_allowed() return res def check_product_with_component_change_allowed(self): + self.ensure_one() if len(self.attribute_line_ids) > 0 and len(self.bom_ids) > 0: for bom in self.bom_ids: for line in bom.bom_line_ids.filtered( @@ -38,6 +39,7 @@ class ProductTemplate(models.Model): ) def check_component_change_allowed(self): + self.ensure_one() if len(self.attribute_line_ids) > 0: boms = self.get_component_boms() if boms: @@ -60,6 +62,7 @@ class ProductTemplate(models.Model): ) def get_component_boms(self): + self.ensure_one() bom_lines = self.env["mrp.bom.line"].search( [("component_template_id", "=", self._origin.id)] )