Skip to content

Commit

Permalink
[16.0][FIX] mrp_bom_line_layer_and_designator: Fix error when the sam…
Browse files Browse the repository at this point in the history
…e product exists more than once in a BOM.
  • Loading branch information
alfredoavanzosc authored and anajuaristi committed Feb 28, 2025
1 parent 3065886 commit 8ff6dfd
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ def _get_bom_data(
for line in res["components"]:
bom_line = line_ids.filtered(
lambda ln: ln.product_id.display_name == line["name"]
and ln.product_qty == line["quantity"]
)
if len(bom_line) > 1:
bom_line = self._find_untreated(bom_line, res)
line.update(
{
"layer": bom_line.layer or "",
Expand Down Expand Up @@ -84,11 +87,30 @@ def _get_pdf_line(
for line in res["lines"]:
line_id = line_ids.filtered(
lambda ln: ln.product_id.display_name == line["name"]
and ln.product_qty == line["quantity"]
)
if len(line_id) > 1:
line_id = self._find_untreated(line_id, res)
line.update(
{
"layer": line_id.layer or "",
"designator": line_id.designator or "",
}
)
return res

def _find_untreated(self, bom_lines, res):
for bom_line in bom_lines:
bom_line_treated = self.env["mrp.bom.line"]
for line in res["components"]:
if (
line["name"] == bom_line.product_id.display_name
and line["quantity"] == bom_line.product_qty
and "layer" in line
and bom_line.layer == line.get("layer")
and "designator" in line
and bom_line.designator == line.get("designator")
):
bom_line_treated += bom_line
if not bom_line_treated:
return bom_line

0 comments on commit 8ff6dfd

Please sign in to comment.