Skip to content

Commit

Permalink
FIX test and adds more info in configured bom data
Browse files Browse the repository at this point in the history
  • Loading branch information
FranzPoize committed Apr 18, 2024
1 parent aeb2656 commit da62e7d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
19 changes: 7 additions & 12 deletions mrp_bom_configurable/models/demo_input_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,13 @@ def create(self, vals_list):
vals[element] = config[element]
return super().create(vals_list)

def _get_config_elements(self):
return CONFIG_ELEMENTS

def populate_bom_data_preview(self):
self.ensure_one()
elements = dict()
for elm in CONFIG_ELEMENTS:
if self._fields[elm].type == "many2one":
value = self[elm].display_name
else:
value = self[elm]
elements[elm] = value

bom = self.bom_id
content = bom.check_domain(elements)
content = bom.get_bom_configured_data(self)
self.env["mrp.bom"].create(
{
"product_tmpl_id": bom.product_tmpl_id.id,
Expand All @@ -54,9 +49,9 @@ def populate_bom_data_preview(self):
0,
0,
{
"product_id": line.product_id.id,
"product_qty": line.product_qty,
"product_uom_id": line.product_uom_id.id,
"product_id": line["product_id"].id,
"product_qty": line["product_qty"],
"product_uom_id": line["product_uom_id"].id,
},
)
for line in content
Expand Down
1 change: 1 addition & 0 deletions mrp_bom_configurable/models/mrp_bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def _compute_data_from_line_and_quantity(self, line, line_quantity):
"product_tmpl_id": line.product_tmpl_id,
"product_id": line.product_id,
"product_qty": line_quantity,
"product_uom_id": line.product_uom_id
}

def get_bom_configured_data(self, input_line, quantity=1.0):
Expand Down
2 changes: 1 addition & 1 deletion mrp_bom_configurable/tests/test_mrp_bom_configurable.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def setUpClass(cls):
"product_id": cls.component_2.id,
"bom_id": cls.bom.id,
"product_qty": 2.0,
"domain": "['OR', ('test_config', '==', True), ('test_config', '==', True)]",
"domain": "['|', ('test_config', '==', True), ('test_config', '==', True)]",
}
)
cls.line_2 = cls.bom_line_obj.create(
Expand Down

0 comments on commit da62e7d

Please sign in to comment.