Skip to content

Commit

Permalink
[FIX] mrp_multi_level: when a product is a kit does not check rule
Browse files Browse the repository at this point in the history
When you procure a kit, it doesn't matter what the routes configuration
is on the product itself but its children, so it is not needed to check
anything else but the BoM to assign the 'phantom' supply  method.

Also do not assign a BoM when the supply method is not phantom or manufacture.
  • Loading branch information
LoisRForgeFlow committed Nov 25, 2024
1 parent 08fccec commit 77f8f87
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions mrp_multi_level/models/product_mrp_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,18 +213,19 @@ def _compute_supply_method(self):
boms_by_product = self.env["mrp.bom"]._bom_find(self.mapped("product_id"))
for rec in self:
rule = rec._get_rule()
if not rule:
bom = boms_by_product.get(rec.product_id, self.env["mrp.bom"])
if bom.type == "phantom":
rec.supply_method = "phantom"
rec.supply_bom_id = bom
elif not rule:
rec.supply_method = "none"
rec.supply_bom_id = False
continue
# Determine the supply method based on the final rule.
bom = boms_by_product.get(rec.product_id, self.env["mrp.bom"])
rec.supply_method = (
"phantom"
if rule.action == "manufacture" and bom.type == "phantom"
else rule.action
)
rec.supply_bom_id = bom
elif rule.action == "manufacture":
rec.supply_method = rule.action
rec.supply_bom_id = bom
else:
rec.supply_method = rule.action
rec.supply_bom_id = False

@api.depends(
"mrp_area_id", "supply_method", "product_id.route_ids", "product_id.seller_ids"
Expand Down

0 comments on commit 77f8f87

Please sign in to comment.