[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#62668 X-original-commit: 5b07432af890794742697641a593fc649630316f Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user