Skip to content

Commit

Permalink
Merge PR #1331 into 15.0
Browse files Browse the repository at this point in the history
Signed-off-by LoisRForgeFlow
  • Loading branch information
OCA-git-bot committed Jul 31, 2024
2 parents 6cecd3b + a32c519 commit 3c59629
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions mrp_multi_level/models/product_mrp_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,31 +178,38 @@ def _compute_qty_available(self):
location=rec._get_locations().ids
).qty_available

def _compute_supply_method(self):
def _get_rule(self):
self.ensure_one()
group_obj = self.env["procurement.group"]
proc_loc = self.location_proc_id or self.location_id
values = {
"warehouse_id": self.mrp_area_id.warehouse_id,
"company_id": self.company_id,
}
rule = group_obj._get_rule(self.product_id, proc_loc, values)
if not rule:
return False
# Keep getting the rule for the product and the source location until the
# action is "buy" or "manufacture". Or until the action is "Pull From" or
# "Pull & Push" and the supply method is "Take from Stock".
while rule.action not in ("buy", "manufacture") and rule.procure_method in (
"make_to_order",
"mts_else_mto",
):
new_rule = group_obj._get_rule(
self.product_id, rule.location_src_id, values
)
if not new_rule:
break
rule = new_rule
return rule

def _compute_supply_method(self):
for rec in self:
proc_loc = rec.location_proc_id or rec.location_id
values = {
"warehouse_id": rec.mrp_area_id.warehouse_id,
"company_id": rec.company_id,
}
rule = group_obj._get_rule(rec.product_id, proc_loc, values)
rule = rec._get_rule()
if not rule:
rec.supply_method = "none"
continue
# Keep getting the rule for the product and the source location until the
# action is "buy" or "manufacture". Or until the action is "Pull From" or
# "Pull & Push" and the supply method is "Take from Stock".
while rule.action not in ("buy", "manufacture") and rule.procure_method in (
"make_to_order",
"mts_else_mto",
):
new_rule = group_obj._get_rule(
rec.product_id, rule.location_src_id, values
)
if not new_rule:
break
rule = new_rule
# Determine the supply method based on the final rule.
boms = rec.product_id.product_tmpl_id.bom_ids.filtered(
lambda x: x.type in ["normal", "phantom"]
Expand Down

0 comments on commit 3c59629

Please sign in to comment.