Merge PR #1326 into 16.0

Signed-off-by LoisRForgeFlow
This commit is contained in:
OCA-git-bot
2024-07-29 14:31:15 +00:00
2 changed files with 14 additions and 7 deletions

View File

@@ -300,3 +300,7 @@ class ProductMRPArea(models.Model):
def _get_locations(self):
self.ensure_one()
return self.mrp_area_id._get_locations()
def _should_create_planned_order(self):
self.ensure_one()
return not self.supply_method == "phantom"

View File

@@ -274,7 +274,7 @@ class MultiLevelMrp(models.TransientModel):
)
# Do not create planned order for products that are Kits
planned_order = False
if not product_mrp_area_id.supply_method == "phantom":
if product_mrp_area_id._should_create_planned_order():
planned_order = self.env["mrp.planned.order"].create(order_data)
qty_ordered = qty_ordered + qty
@@ -873,6 +873,14 @@ class MultiLevelMrp(models.TransientModel):
if invs:
po.mrp_inventory_id = invs[0]
def should_build_time_phased_inventory(self, product_mrp_area):
return not (
self._exclude_from_mrp(
product_mrp_area.product_id, product_mrp_area.mrp_area_id
)
or product_mrp_area.supply_method == "phantom"
)
@api.model
def _mrp_final_process(self, mrp_areas):
logger.info("Start MRP final process")
@@ -883,12 +891,7 @@ class MultiLevelMrp(models.TransientModel):
for product_mrp_area in product_mrp_area_ids:
# Build the time-phased inventory
if (
self._exclude_from_mrp(
product_mrp_area.product_id, product_mrp_area.mrp_area_id
)
or product_mrp_area.supply_method == "phantom"
):
if not self.should_build_time_phased_inventory(product_mrp_area):
continue
self._init_mrp_inventory(product_mrp_area)
logger.info("End MRP final process")