From 13b3c07d428ad9e4eb415d4be40353e1ceffbc8e Mon Sep 17 00:00:00 2001 From: Carlos Lopez Date: Wed, 19 Feb 2025 11:33:09 -0500 Subject: [PATCH] [FIX] product_label_section_and_note_field: Update name directly before calling update to prevent a race condition. --- ...roduct_label_section_and_note_field.esm.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/web_widget_product_label_section_and_note/static/src/components/product_label_section_and_note_field/product_label_section_and_note_field.esm.js b/web_widget_product_label_section_and_note/static/src/components/product_label_section_and_note_field/product_label_section_and_note_field.esm.js index f35a6730c..054a5f914 100644 --- a/web_widget_product_label_section_and_note/static/src/components/product_label_section_and_note_field/product_label_section_and_note_field.esm.js +++ b/web_widget_product_label_section_and_note/static/src/components/product_label_section_and_note_field/product_label_section_and_note_field.esm.js @@ -261,14 +261,17 @@ export class ProductLabelSectionAndNoteField extends Many2OneField { updateLabel(value) { this.changeProductVisibility = false; - this.props.record.update({ - name: - this.productName && - this.productName !== value && - this.isProductVisible.value - ? `${this.productName}\n${value}` - : value, - }); + const new_name = + this.productName && + this.productName !== value && + this.isProductVisible.value + ? `${this.productName}\n${value}` + : value; + // We need to update the record data directly because the record.update method + // updates the data asynchronously, and the new value will not be available + // in the `get Label` method immediately. + this.props.record.data.name = new_name; + this.props.record.update({name: new_name}); } }