From 2c756c3d6f0fa5a61d9dd4c11435fb7e073b50b3 Mon Sep 17 00:00:00 2001 From: clesgow Date: Thu, 4 May 2023 11:06:20 +0200 Subject: [PATCH] [FIX] mrp: remove unnecessary transit line on MTO overview When displaying the MO Overview of a MTO product, "In Transit" lines would be displayed for MTO components until the component was consumed. Now checks whether the component is ready to be consumed (i.e. its reservation is the MO itself, not a picking before) to know if it should display the transit line or not. Part of task-3251506 Part-of: odoo/odoo#114536 --- addons/mrp/report/mrp_report_mo_overview.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/mrp/report/mrp_report_mo_overview.py b/addons/mrp/report/mrp_report_mo_overview.py index b9db52667da..e5ab9181e14 100644 --- a/addons/mrp/report/mrp_report_mo_overview.py +++ b/addons/mrp/report/mrp_report_mo_overview.py @@ -426,8 +426,13 @@ class ReportMoOverview(models.AbstractModel): return replenishments def _add_transit_line(self, move_raw, forecast, production, level, current_index): - in_transit = next(filter(lambda line: line.get('in_transit') and line.get('document_out') and line['document_out'].get('id') == production.id, forecast), None) - if not in_transit: + def is_related_to_production(document, production): + if not document: + return False + return document.get('_name') == production._name and document.get('id') == production.id + + in_transit = next(filter(lambda line: line.get('in_transit') and is_related_to_production(line.get('document_out'), production), forecast), None) + if not in_transit or is_related_to_production(in_transit.get('reservation'), production): return None product = move_raw.product_id