From 688b3c6a750acd5afb997f420ccdb871dd70e06a Mon Sep 17 00:00:00 2001 From: Nikul-OSI Date: Tue, 6 Aug 2024 10:44:28 +0530 Subject: [PATCH] [IMP] Improved code for scaffolding bom --- product_configurator_mrp_component/models/mrp_bom.py | 6 ++++-- .../models/product_config.py | 10 ++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/product_configurator_mrp_component/models/mrp_bom.py b/product_configurator_mrp_component/models/mrp_bom.py index e6eec7f78..ef9e67b0c 100644 --- a/product_configurator_mrp_component/models/mrp_bom.py +++ b/product_configurator_mrp_component/models/mrp_bom.py @@ -44,12 +44,14 @@ def _compute_available_config_components(self): prod_vals = prod.mapped( "attribute_line_ids.value_ids" ).filtered( - lambda m: m.attribute_id == attribute_line.attribute_id + lambda m, attribute_line: m.attribute_id + == attribute_line.attribute_id ) bom_tmpl_values = bom.product_tmpl_id.mapped( "attribute_line_ids.value_ids" ).filtered( - lambda m: m.attribute_id == attribute_line.attribute_id + lambda m, attribute_line: m.attribute_id + == attribute_line.attribute_id ) # If bom prod has all vals that conf comp has then add it if all(att_val in bom_tmpl_values for att_val in prod_vals): diff --git a/product_configurator_mrp_component/models/product_config.py b/product_configurator_mrp_component/models/product_config.py index ed1d39408..a7ce32271 100644 --- a/product_configurator_mrp_component/models/product_config.py +++ b/product_configurator_mrp_component/models/product_config.py @@ -13,10 +13,20 @@ def create_get_bom(self, variant, product_tmpl_id=None, values=None): [ ("product_tmpl_id", "=", product_tmpl_id.id), ("product_id", "=", False), + ("scaffolding_bom", "=", True), ], order="sequence asc", limit=1, ) + if not master_bom: + master_bom = self.env["mrp.bom"].search( + [ + ("product_tmpl_id", "=", product_tmpl_id.id), + ("product_id", "=", False), + ], + order="sequence asc", + limit=1, + ) vals = False wizard_values = variant.product_template_attribute_value_ids.mapped( "product_attribute_value_id"