diff --git a/mrp_bom_configurable/__manifest__.py b/mrp_bom_configurable/__manifest__.py index 68d7300bed..21d6f6d611 100644 --- a/mrp_bom_configurable/__manifest__.py +++ b/mrp_bom_configurable/__manifest__.py @@ -21,7 +21,6 @@ "views/input_line.xml", "views/input_line_wizard.xml", ], - "demo": [ - ], + "demo": [], "installable": True, } diff --git a/mrp_bom_configurable/models/mrp_bom.py b/mrp_bom_configurable/models/mrp_bom.py index 8ddfa405de..a155b38ef9 100644 --- a/mrp_bom_configurable/models/mrp_bom.py +++ b/mrp_bom_configurable/models/mrp_bom.py @@ -55,8 +55,11 @@ def find_parent_bom_in_exploded(self, boms_done, parent_bom_id): return parent_bom_data def _recompute_variable_quantity(self, quantity, input_line, boms_done, lines_done): - for bom, bom_data in boms_done: - if bom_data["parent_line"] and bom_data["parent_line"].use_formula_compute_qty: + for _, bom_data in boms_done: + if ( + bom_data["parent_line"] + and bom_data["parent_line"].use_formula_compute_qty + ): bom_data["qty"] = bom_data["original_qty"] * bom_data[ "parent_line" ].compute_qty_from_formula(input_line) @@ -64,19 +67,11 @@ def _recompute_variable_quantity(self, quantity, input_line, boms_done, lines_do for bom_line, line_data in lines_done: parent_line = line_data["parent_line"] - parent_quantity = 1 - if line_data["parent_line"] and parent_line.bom_id.type == "phantom": - parent_bom_data = self.find_parent_bom_in_exploded( - boms_done, line_data["parent_line"].bom_id - ) - parent_quantity = parent_bom_data["qty"] - - line_data["qty"] = parent_quantity * line_data["qty"] + line_data["qty"] = line_data["qty"] if bom_line.use_formula_compute_qty: - line_data["qty"] = ( - line_data["qty"] - * bom_line.compute_qty_from_formula(input_line) + line_data["qty"] = line_data["qty"] * bom_line.compute_qty_from_formula( + input_line ) while parent_line and parent_line.bom_id.type == "phantom": @@ -99,4 +94,3 @@ def explode(self, product, quantity, picking_type=False): quantity, input_line, boms_done, lines_done ) return boms_done, lines_done - diff --git a/mrp_bom_configurable/models/mrp_bom_line.py b/mrp_bom_configurable/models/mrp_bom_line.py index e55e5f90c3..99f3375eb4 100644 --- a/mrp_bom_configurable/models/mrp_bom_line.py +++ b/mrp_bom_configurable/models/mrp_bom_line.py @@ -21,6 +21,21 @@ def check_domain(domain, values, current_name, parent_name): if len(domain) == 1: domain.append(True) + + # make domain a proper PN input + # a = [o, d, d, d, d, o, d, d] + # a = [o, d, d, d, o, d, o, d, d] + # a = [o, d, d, o, d, o, d, o, d, d] + # a = [o, d, d, o, d, o, d, o, d, d] + # a = [o, d, o, d, o, d, o, d, o, d, d] + current_index = len(domain) - 2 + while current_index > 0: + if domain[current_index - 1] not in ["&", "|"]: + domain.insert(current_index, "&") + current_index += 1 + current_index -= 2 + + # This check the front of the domain which should always be a operator if domain[0] not in ["&", "|"]: domain.insert(0, "&") @@ -98,7 +113,9 @@ def _create_context(self, input_line): context[param] = input_line[param] math_module = __import__("math") - math = wrap_module(math_module, [f for f in math_module.__dict__ if "__" not in f]) + math = wrap_module( + math_module, [f for f in math_module.__dict__ if "__" not in f] + ) context["math"] = math return context diff --git a/mrp_bom_configurable/views/bom.xml b/mrp_bom_configurable/views/bom.xml index afc66eff8d..a016f561bd 100644 --- a/mrp_bom_configurable/views/bom.xml +++ b/mrp_bom_configurable/views/bom.xml @@ -12,7 +12,7 @@ expr="//field[@name='bom_line_ids']/tree/field[@name='product_uom_id']" position="after" > - +