From b4f36b45c77c7c3ea4d7dff48b2de1e9d6528322 Mon Sep 17 00:00:00 2001 From: "Mathias Mathy (MAMA)" Date: Thu, 27 Oct 2022 08:47:50 +0000 Subject: [PATCH] [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) --- .../static/src/widgets/mrp_should_consume.js | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/addons/mrp/static/src/widgets/mrp_should_consume.js b/addons/mrp/static/src/widgets/mrp_should_consume.js index e33beab9353..12d3148f31b 100644 --- a/addons/mrp/static/src/widgets/mrp_should_consume.js +++ b/addons/mrp/static/src/widgets/mrp_should_consume.js @@ -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";