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..8011ecb91 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" @@ -28,7 +38,8 @@ def create_get_bom(self, variant, product_tmpl_id=None, values=None): vals = set(wizard_values.ids).intersection( set(config_component_vals.ids) ) - # Bypass config component variant creation if not all required vals are set + # Bypass config component variant creation + # if not all required vals are set do_not_create = False for line in config_component_line.product_tmpl_id.attribute_line_ids: common_vals = set(vals) & set(line.value_ids.ids)