[FIX] stock: refresh forecast page

Steps to reproduce:
1. Inventory / Configuration / Warehouse Management / Warehouses
2. Need at least 2 warehouses
3. Inventory / Products / Products
4. Click forecasted quantity on a product that has some on hand
5. Click warehouse and select any option
6. Refresh the page
7. Error

Bug:
when refreshing the page the context gets cleared and productID lost
which leads to an error when looking for its bomIDS

Fix:
when refreshing the page get the productID from the url
also set the default title to "Forcasted Report"

opw-3217987

closes odoo/odoo#116198

X-original-commit: d49c73f95033472f1417ee05793d5f100f641dd0
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Walid Hanniche (waha) <waha@odoo.com>
This commit is contained in:
Walid HANNICHE (waha)
2023-03-22 14:52:47 +01:00
parent 10716e4837
commit 5e54ac4ecc
@@ -1,6 +1,7 @@
/** @odoo-module **/
import { useService } from "@web/core/utils/hooks";
import { _t } from "@web/core/l10n/translation";
import { registry } from "@web/core/registry";
import { View } from "@web/views/view";
import { ControlPanel } from "@web/search/control_panel/control_panel";
@@ -20,7 +21,11 @@ export class StockForecasted extends Component {
this.context = useState(this.props.action.context);
this.productId = this.context.active_id;
this.resModel = this.context.active_model;
this.title = this.props.action.name;
this.title = this.props.action.name || _t("Forecasted Report");
if(!this.context.active_id){
this.context.active_id = this.props.action.params.active_id;
this.reloadReport();
}
onWillStart(this._getReportValues);
}