[FIX] mrp: Update "To Consume" on Quantity Change in MO

Steps to reproduce :
    In a Manufacturing Order, update quantity (product_qty)

Expected behavior :
    In the "Components" tab, "To Consume" column should update without Save

Actual behavior :
    Due to "mrp_should_consume" widget not being reactive, should_consume_qty is not updated in the view until it's saved.

closes odoo/odoo#104364

Task: 2985735
X-original-commit: b3ec31d89eb635b555f77b3eb9ecaac4c65981e6
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
This commit is contained in:
Mathias Mathy (MAMA)
2022-11-07 10:06:21 +01:00
parent eccf8ab4e5
commit b4f36b45c7
@@ -12,16 +12,13 @@ import { formatFloat } from "@web/views/fields/formatters";
* The widget will be '3.000 / 5.000'.
*/
const { useRef, onPatched, onMounted } = owl;
const { useRef, onPatched, onMounted, useState } = owl;
export class MrpShouldConsumeOwl extends FloatField {
setup() {
super.setup();
const { data, fields } = this.props.record;
this.shouldConsumeQty = formatFloat(data.should_consume_qty, {
...fields.should_consume_qty,
...this.nodeOptions,
});
this.displayShouldConsume = !["done", "draft", "cancel"].includes(data.state);
this.fields = this.props.record.fields;
this.record = useState(this.props.record);
this.displayShouldConsume = !["done", "draft", "cancel"].includes(this.record.data.state);
this.inputSpanRef = useRef("numpadDecimal");
onMounted(this._renderPrefix);
onPatched(this._renderPrefix);
@@ -37,7 +34,14 @@ export class MrpShouldConsumeOwl extends FloatField {
);
}
}
}
get shouldConsumeQty() {
return formatFloat(this.record.data.should_consume_qty, {
...this.fields.should_consume_qty,
...this.nodeOptions,
});
}
}
MrpShouldConsumeOwl.template = "mrp.ShouldConsume";
MrpShouldConsumeOwl.displayName = "MRP Should Consume";