Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][IMP] mrp_multi_level: better logs during calculation #1344

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 24 additions & 15 deletions mrp_multi_level/wizards/mrp_multi_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,30 +720,39 @@ def _exclude_move(self, move):
"""Improve extensibility being able to exclude special moves."""
return False

@api.model
def _mrp_calculation(self, mrp_lowest_llc, mrp_areas):
logger.info("Start MRP calculation")
def _get_mrp_initialization_groups_of_params(self, mrp_lowest_llc, mrp_areas):
product_mrp_area_obj = self.env["product.mrp.area"]
counter = 0
if not mrp_areas:
mrp_areas = self.env["mrp.area"].search([])
groups = {}
for mrp_area in mrp_areas:
llc = 0
while mrp_lowest_llc > llc:
product_mrp_areas = product_mrp_area_obj.search(
groups[mrp_area, llc] = product_mrp_area_obj.search(
[("product_id.llc", "=", llc), ("mrp_area_id", "=", mrp_area.id)]
)
llc += 1
return groups

for product_mrp_area in product_mrp_areas:
if product_mrp_area.mrp_nbr_days == 0:
self._init_mrp_move_non_grouped_demand(product_mrp_area)
else:
self._init_mrp_move_grouped_demand(product_mrp_area)
counter += 1
@api.model
def _mrp_calculation(self, mrp_lowest_llc, mrp_areas):
logger.info("Start MRP calculation")
if not mrp_areas:
mrp_areas = self.env["mrp.area"].search([])
keyed_groups = self._get_mrp_initialization_groups_of_params(
mrp_lowest_llc, mrp_areas
)
for (mrp_area, llc), product_mrp_areas in keyed_groups.items():
counter = 0
for product_mrp_area in product_mrp_areas:
if product_mrp_area.mrp_nbr_days == 0:
self._init_mrp_move_non_grouped_demand(product_mrp_area)
else:
self._init_mrp_move_grouped_demand(product_mrp_area)
counter += 1

log_msg = "MRP Calculation LLC {} Finished - Nbr. products: {}".format(
llc - 1, counter
log_msg = (
"MRP Calculation LLC {} at {} Finished - Nbr. products: {}".format(
llc, mrp_area.name, counter
)
)
logger.info(log_msg)

Expand Down
Loading