mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
@@ -213,18 +213,19 @@ class ProductMRPArea(models.Model):
|
|||||||
boms_by_product = self.env["mrp.bom"]._bom_find(self.mapped("product_id"))
|
boms_by_product = self.env["mrp.bom"]._bom_find(self.mapped("product_id"))
|
||||||
for rec in self:
|
for rec in self:
|
||||||
rule = rec._get_rule()
|
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_method = "none"
|
||||||
rec.supply_bom_id = False
|
rec.supply_bom_id = False
|
||||||
continue
|
elif rule.action == "manufacture":
|
||||||
# Determine the supply method based on the final rule.
|
rec.supply_method = rule.action
|
||||||
bom = boms_by_product.get(rec.product_id, self.env["mrp.bom"])
|
rec.supply_bom_id = bom
|
||||||
rec.supply_method = (
|
else:
|
||||||
"phantom"
|
rec.supply_method = rule.action
|
||||||
if rule.action == "manufacture" and bom.type == "phantom"
|
rec.supply_bom_id = False
|
||||||
else rule.action
|
|
||||||
)
|
|
||||||
rec.supply_bom_id = bom
|
|
||||||
|
|
||||||
@api.depends(
|
@api.depends(
|
||||||
"mrp_area_id", "supply_method", "product_id.route_ids", "product_id.seller_ids"
|
"mrp_area_id", "supply_method", "product_id.route_ids", "product_id.seller_ids"
|
||||||
|
|||||||
@@ -451,6 +451,16 @@ class TestMrpMultiLevel(TestMrpMultiLevelCommon):
|
|||||||
]
|
]
|
||||||
product_mrp_area._compute_supply_method()
|
product_mrp_area._compute_supply_method()
|
||||||
self.assertEqual(product_mrp_area.supply_method, "buy")
|
self.assertEqual(product_mrp_area.supply_method, "buy")
|
||||||
|
kit_bom = self.mrp_bom_obj.create(
|
||||||
|
{
|
||||||
|
"product_tmpl_id": self.fp_4.product_tmpl_id.id,
|
||||||
|
"product_id": self.fp_4.id,
|
||||||
|
"type": "phantom",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
product_mrp_area._compute_supply_method()
|
||||||
|
self.assertEqual(product_mrp_area.supply_method, "phantom")
|
||||||
|
self.assertEqual(product_mrp_area.supply_bom_id, kit_bom)
|
||||||
|
|
||||||
def test_18_priorize_safety_stock(self):
|
def test_18_priorize_safety_stock(self):
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
|
|||||||
Reference in New Issue
Block a user