From 784f90d25614e4816ac3ed26f0643b562071edbd Mon Sep 17 00:00:00 2001 From: "Thomas Lefebvre (thle)" Date: Tue, 19 Mar 2024 13:05:32 +0100 Subject: [PATCH] [FIX] stock: add active model in report context Steps to reproduce: ------------------- - create a storable product and set a quantity on hand - create a delivery for this product and set to draft - add a demand for this product on the delivery - click on "Mark as Todo" - go to the product form - click on the Forecasted smart button - click on "Unreserve" button (to process business logic ans reload report) Issue: ------ The report is reloaded with all products. Cause: ------ When we setup/start the `StockForecasted` component, if we can't find an active model in the action's context, we try to find it in the action's props (via res_model or on the original action if necessary). If the original action is used, the active model must be in the context of the original action. Unfortunately, this is not the case. Without `resModel` the domain determined in the `graphDomain` method will not filter on the product (which corresponds to the `active_id`). Solution: --------- If no resModel is found via the context, add it to the context when it is determined. Add the action id to handle the case of reloading the page directly via the browser's refresh button. opw-3793065 closes odoo/odoo#161569 X-original-commit: 288e1e0f8d7bc343b90a22692bdf44ccb9b21725 Signed-off-by: William Henrotin (whe) Signed-off-by: Thomas Lefebvre (thle) --- addons/stock/static/src/stock_forecasted/stock_forecasted.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/stock/static/src/stock_forecasted/stock_forecasted.js b/addons/stock/static/src/stock_forecasted/stock_forecasted.js index e999124604e..bb0af873beb 100644 --- a/addons/stock/static/src/stock_forecasted/stock_forecasted.js +++ b/addons/stock/static/src/stock_forecasted/stock_forecasted.js @@ -63,6 +63,7 @@ export class StockForecasted extends Component { this.resModel = originalContextAction.active_model; } } + this.context.active_model = this.resModel; } } @@ -76,6 +77,7 @@ export class StockForecasted extends Component { async reloadReport() { const actionRequest = { + id: this.props.action.id, type: "ir.actions.client", tag: "stock_forecasted", context: this.context,