Skip to content

Commit

Permalink
pre-commit pass
Browse files Browse the repository at this point in the history
  • Loading branch information
FranzPoize committed Nov 21, 2024
1 parent 393ff1a commit d8c6e38
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 18 deletions.
3 changes: 1 addition & 2 deletions mrp_bom_configurable/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"views/input_line.xml",
"views/input_line_wizard.xml",
],
"demo": [
],
"demo": [],
"installable": True,
}
22 changes: 8 additions & 14 deletions mrp_bom_configurable/models/mrp_bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,23 @@ 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)

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":
Expand All @@ -99,4 +94,3 @@ def explode(self, product, quantity, picking_type=False):
quantity, input_line, boms_done, lines_done
)
return boms_done, lines_done

19 changes: 18 additions & 1 deletion mrp_bom_configurable/models/mrp_bom_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, "&")

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion mrp_bom_configurable/views/bom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
expr="//field[@name='bom_line_ids']/tree/field[@name='product_uom_id']"
position="after"
>
<field name="domain">
<field name="domain" />
<button
name="ui_update_domain"
type="object"
Expand Down

0 comments on commit d8c6e38

Please sign in to comment.