Skip to content

Commit

Permalink
[FIX] web_widget_product_label_section_and_note: Use a flag to change…
Browse files Browse the repository at this point in the history
… the icon based on product visibility.

Before this commit, when isProductVisible was disabled and the user changed the label, this caused isProductVisible to change its value.
After this commit, changing the label no longer modifies isProductVisible.
  • Loading branch information
carlos-lopez-tecnativa committed Feb 6, 2025
1 parent bc4f109 commit 65af83d
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ export class ProductLabelSectionAndNoteField extends Many2OneField {
this.labelVisibility = useState({value: false});
this.isProductVisible = useState({value: false});
this.switchToLabel = false;
this.changeProductVisibility = true;
this.columnIsProductAndLabel = useState({
value: this.props.record.columnIsProductAndLabel,
});
Expand Down Expand Up @@ -203,8 +204,10 @@ export class ProductLabelSectionAndNoteField extends Many2OneField {
window.removeEventListener("afterprint", this.onAfterPrint);
});
useRecordObserver(async (record) => {
const label = record.data.name || "";
this.isProductVisible.value = label.includes(this.productName);
if (this.changeProductVisibility) {
const label = record.data.name || "";
this.isProductVisible.value = label.includes(this.productName);
}
});
}

Expand Down Expand Up @@ -276,9 +279,12 @@ export class ProductLabelSectionAndNoteField extends Many2OneField {
}

updateLabel(value) {
this.changeProductVisibility = false;
this.props.record.update({
name:
this.productName && this.productName !== value
this.productName &&
this.productName !== value &&
this.isProductVisible.value
? `${this.productName}\n${value}`
: value,
});
Expand Down

0 comments on commit 65af83d

Please sign in to comment.