diff --git a/addons/stock/static/src/js/report_stock_forecasted.js b/addons/stock/static/src/js/report_stock_forecasted.js index 4ad8bff2710..df2ff1a02bf 100644 --- a/addons/stock/static/src/js/report_stock_forecasted.js +++ b/addons/stock/static/src/js/report_stock_forecasted.js @@ -28,7 +28,7 @@ const ReplenishReport = clientAction.extend({ this._super.apply(this, arguments); this.context = action.context; this.productId = this.context.active_id; - this.resModel = this.context.active_model || 'product.template'; + this.resModel = this.context.active_model || this.context.params.active_model || 'product.template'; const isTemplate = this.resModel === 'product.template'; this.actionMethod = `action_product_${isTemplate ? 'tmpl_' : ''}forecast_report`; const reportName = `report_product_${isTemplate ? 'template' : 'product'}_replenishment`; @@ -81,6 +81,11 @@ const ReplenishReport = clientAction.extend({ in_DOM: true, callbacks: [{ widget: graphController }], }); + // Hack to put the res_model on the url. This way, the report always know on with res_model it refers. + if (location.href.indexOf('active_model') === -1) { + const url = window.location.href + `&active_model=${this.resModel}`; + window.history.pushState({}, "", url); + } }, /**