From ea6b120524002dbf89f3efed4ee8eeb7190dce67 Mon Sep 17 00:00:00 2001 From: clesgow Date: Fri, 28 Jul 2023 13:44:57 +0200 Subject: [PATCH] [FIX] mrp: display correct quantity following production warehouse Steps to reproduce: - Enable multi-warehouse - Add different quantities for a component on two different warehouse - Create a MO on each warehouse using that component - Open Overview for each MO Issue: Both Overview display the sum of both warehouses quantities in "Free to use / On Hand" column, which is incorrect. By forcing the context to contain the warehouse_id, the quantities fetched on the products will correspond to the quantities in each warehouses. Note: It's necessary to update the context of the fetched production as most computation is done from this record, and its own context isn't modified by the addition of `warehouse` to the context of `self`. Task-3251506 Part-of: odoo/odoo#114536 --- addons/mrp/report/mrp_report_mo_overview.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/mrp/report/mrp_report_mo_overview.py b/addons/mrp/report/mrp_report_mo_overview.py index 47c2ce4a452..b9db52667da 100644 --- a/addons/mrp/report/mrp_report_mo_overview.py +++ b/addons/mrp/report/mrp_report_mo_overview.py @@ -52,6 +52,9 @@ class ReportMoOverview(models.AbstractModel): def _get_report_data(self, production_id): production = self.env['mrp.production'].browse(production_id) + # Necessary to fetch the right quantities for multi-warehouse + production = production.with_context(warehouse=production.warehouse_id.id) + components = self._get_components_data(production, level=1, current_index='') operations = self._get_operations_data(production, level=1, current_index='') initial_mo_cost = sum(component.get('summary', {}).get('mo_cost', 0.0) for component in components)\