From 49bec71d1289e39e9e5ad0de32ddde1f4f3acc5c Mon Sep 17 00:00:00 2001 From: aamo-odoo Date: Mon, 18 Mar 2024 20:44:40 +0530 Subject: [PATCH] [FIX] stock_account: prevent error if warehouse location not found. An error occurs when the user attempts to access a forecast report for the replenishment product but does not receive the warehouse location ID (archive/delete). Steps to reproduce: (without demo data) - Install "stock_account" module - Inventory -> Operation -> Procurement -> Replenishment - Create a new Replenishment product - Configuration -> warehouse -> Archive warehouse records - Go to a product made in the replenishment and click on forecast report Traceback : "IndexError list index out of range" This commit will help to open a forecast report if the warehouse location is not found. sentry-4998176742 closes odoo/odoo#158017 Signed-off-by: Adrien Widart (awt) --- addons/stock_account/report/stock_forecasted.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock_account/report/stock_forecasted.py b/addons/stock_account/report/stock_forecasted.py index 85020ddf567..db29a54307f 100644 --- a/addons/stock_account/report/stock_forecasted.py +++ b/addons/stock_account/report/stock_forecasted.py @@ -11,7 +11,7 @@ class StockForecasted(models.AbstractModel): def _get_report_header(self, product_template_ids, product_ids, wh_location_ids): """ Overrides to computes the valuations of the stock. """ res = super()._get_report_header(product_template_ids, product_ids, wh_location_ids) - if not self.user_has_groups('stock.group_stock_manager'): + if not self.user_has_groups('stock.group_stock_manager') or not wh_location_ids: return res domain = self._product_domain(product_template_ids, product_ids) company = self.env['stock.location'].browse(wh_location_ids[0]).company_id