[FIX] stock: disabled forecasted button new line

In One2many tree of stock.move, the forecasted button trigger
a traceback in case of new line because there isn't a target record.
Also, don't show forecasted information when the state of the move
is 'cancel'.

X-original-commit: a1285d16ff32fb31f202ebe01a6afa83e14b9c14
This commit is contained in:
Rémy Voet (ryv)
2020-10-19 10:51:04 +00:00
parent 8b74d39f71
commit 86fd789846
2 changed files with 5 additions and 2 deletions
@@ -53,6 +53,9 @@ const ForecastWidgetField = AbstractField.extend({
_onOpenReport: function (ev) {
ev.preventDefault();
ev.stopPropagation();
if (!this.recordData.id) {
return;
}
this._rpc({
model: 'stock.move',
method: 'action_product_forecast_report',
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<templates id="template" xml:space="preserve">
<t t-name="stock.forecastWidget">
<span t-if="['draft', 'partially_available', 'assigned'].includes(state)" t-esc="reserved_availability_str"/>
<span t-if="['draft', 'partially_available', 'assigned', 'cancel', 'done'].includes(state)" t-esc="reserved_availability_str"/>
<span t-elif="!forecast_expected_date_str and will_be_fulfilled" class="text-success">Available</span>
<span t-elif="forecast_expected_date_str and will_be_fulfilled" t-att-class="forecast_is_late ? 'text-danger' : 'text-warning'">Exp <t t-esc="forecast_expected_date_str"/></span>
<span t-else="" class="text-danger">Not Available</span>
<button t-if="product_type == 'product'" class="o_forecast_report_button btn btn-link o_icon_button ml-2" title="Forecasted Report">
<button t-if="product_type == 'product'" t-att="id ? {} : {'disabled': ''}" class="o_forecast_report_button btn btn-link o_icon_button ml-2" title="Forecasted Report">
<i t-attf-class="fa fa-fw fa-area-chart {{ state != 'draft' and (!will_be_fulfilled or forecast_is_late) ? 'text-danger' : '' }}"/>
</button>
</t>