diff --git a/mrp_multi_level/models/product_mrp_area.py b/mrp_multi_level/models/product_mrp_area.py index 695d51347d..9207a3fda3 100644 --- a/mrp_multi_level/models/product_mrp_area.py +++ b/mrp_multi_level/models/product_mrp_area.py @@ -300,3 +300,7 @@ def _to_be_exploded(self): 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" diff --git a/mrp_multi_level/wizards/mrp_multi_level.py b/mrp_multi_level/wizards/mrp_multi_level.py index 6f7a092211..6a4eb17660 100644 --- a/mrp_multi_level/wizards/mrp_multi_level.py +++ b/mrp_multi_level/wizards/mrp_multi_level.py @@ -274,7 +274,7 @@ def create_planned_order( ) # 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 @@ def _init_mrp_inventory(self, product_mrp_area): 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 @@ def _mrp_final_process(self, mrp_areas): 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")