Skip to content

Commit

Permalink
[IMP] Improved code for scaffolding bom
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikul-OSI committed Aug 6, 2024
1 parent 01e170b commit fd70bb6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
6 changes: 4 additions & 2 deletions product_configurator_mrp_component/models/mrp_bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
16 changes: 14 additions & 2 deletions product_configurator_mrp_component/models/product_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand All @@ -46,7 +57,8 @@ def create_get_bom(self, variant, product_tmpl_id=None, values=None):
component_config_session.action_confirm()
component_variant = component_config_session.product_id

# Look for existing configuration set and if doesn't exist, create it.
# Look for existing configuration set and
# if doesn't exist, create it.
bom_line_config_set = self.env[
"mrp.bom.line.configuration.set"
].search(
Expand Down

0 comments on commit fd70bb6

Please sign in to comment.