summaryrefslogtreecommitdiff
path: root/addons/stock/static
diff options
context:
space:
mode:
authorsvs-odoo <svs@odoo.com>2020-10-16 07:00:30 +0000
committersvs-odoo <svs@odoo.com>2020-11-24 13:01:11 +0000
commit5b07432af890794742697641a593fc649630316f (patch)
tree6d03ebf5fc06346b7491be96b133b1a0731a77dc /addons/stock/static
parent329618e46ba32eb4a36ed709edf44e0f6d184bbd (diff)
[FIX] stock: refresh forecast report
Before this commit, refresh the forecast report can lead to error if this report refer to a product variant (`product.product`). As it lost to which model the report is supposed to refer, it take the one by default (`product.template`) which can lead to error (display a traceback if the ID doesn't exist or display the report for another product if the ID exists). How to reproduce: Open the Forecasted Report for a `product.product` (from the stat button or from the `sale.order.line` widget for example) then refresh the page. task-2362313 issue #59924 closes odoo/odoo#60149 Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
Diffstat (limited to 'addons/stock/static')
-rw-r--r--addons/stock/static/src/js/report_stock_forecasted.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/addons/stock/static/src/js/report_stock_forecasted.js b/addons/stock/static/src/js/report_stock_forecasted.js
index 2cd92a1802c..efe2b2be6ab 100644
--- a/addons/stock/static/src/js/report_stock_forecasted.js
+++ b/addons/stock/static/src/js/report_stock_forecasted.js
@@ -5,7 +5,6 @@ const clientAction = require('report.client_action');
const core = require('web.core');
const dom = require('web.dom');
const GraphView = require('web.GraphView');
-const session = require('web.session');
const qweb = core.qweb;
const _t = core._t;
@@ -19,7 +18,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`;
@@ -112,6 +111,12 @@ const ReplenishReport = clientAction.extend({
return graphView.getController(this);
}).then(res => {
viewController = res;
+
+ // 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);
+ }
const fragment = document.createDocumentFragment();
return viewController.appendTo(fragment);
});