[IMP] mrp_multi_level: Supply method computation for MRP Parameters

For each MRP Parameter, we will calculate its supply method based on the procurement rules path. We will go back in the rules until we find that the action is "buy" or "manufacture", or until the action is "Pull From" or "Pull & Push" and the supply method is "Take from Stock".

This means we will show what the latest rule is if we were to do a procurement. Although it would be possible that the final action does not end up being executed if stock already exists in one of the intermediate locations.
This commit is contained in:
BernatPForgeFlow
2023-02-08 16:37:41 +01:00
parent 2062cf65c5
commit b0a93099ac
4 changed files with 66 additions and 6 deletions

View File

@@ -29,6 +29,7 @@ class TestMrpMultiLevelCommon(TransactionCase):
cls.fp_1 = cls.env.ref("mrp_multi_level.product_product_fp_1")
cls.fp_2 = cls.env.ref("mrp_multi_level.product_product_fp_2")
cls.fp_3 = cls.env.ref("mrp_multi_level.product_product_fp_3")
cls.fp_4 = cls.env.ref("mrp_multi_level.product_product_fp_4")
cls.sf_1 = cls.env.ref("mrp_multi_level.product_product_sf_1")
cls.sf_2 = cls.env.ref("mrp_multi_level.product_product_sf_2")
cls.sf_3 = cls.env.ref("mrp_multi_level.product_product_sf_3")
@@ -219,6 +220,22 @@ class TestMrpMultiLevelCommon(TransactionCase):
cls.product_mrp_area_obj.create(
{"product_id": cls.prod_uom_test.id, "mrp_area_id": cls.mrp_area.id}
)
# Product MRP Parameter to test supply method computation
cls.env.ref("stock.route_warehouse0_mto").active = True
cls.env["stock.rule"].create(
{
"name": "WH2: Main Area → Secondary Area (MTO)",
"action": "pull",
"picking_type_id": cls.env.ref("stock.picking_type_in").id,
"location_src_id": cls.env.ref("stock.stock_location_stock").id,
"location_dest_id": cls.sec_loc.id,
"route_id": cls.env.ref("stock.route_warehouse0_mto").id,
"procure_method": "mts_else_mto",
}
)
cls.product_mrp_area_obj.create(
{"product_id": cls.fp_4.id, "mrp_area_id": cls.secondary_area.id}
)
# Create pickings for Scenario 1:
dt_base = cls.calendar.plan_days(3 + 1, datetime.today())