From ead2e5e964fd79f38d88b93091d9ad27da5cbe0b Mon Sep 17 00:00:00 2001 From: Ahmed Khalaf Date: Fri, 11 Nov 2022 09:21:33 +0000 Subject: [PATCH] [IMP] stock: json widget no longer changes props This commit changes the json widget to no longer edit the `props` of the component as it might cause reactivity issues. closes odoo/odoo#105663 X-original-commit: eb4ae1d79c455b1b9e163beebb98fb1935834194 Signed-off-by: Arnold Moyaux (arm) --- .../stock/static/src/widgets/json_widget.js | 26 +++++++++++-------- .../stock/static/src/widgets/json_widget.xml | 18 ++++++------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/addons/stock/static/src/widgets/json_widget.js b/addons/stock/static/src/widgets/json_widget.js index be8f9b910fa..2fde6c285f4 100644 --- a/addons/stock/static/src/widgets/json_widget.js +++ b/addons/stock/static/src/widgets/json_widget.js @@ -4,18 +4,22 @@ import { registry } from "@web/core/registry"; import { _lt } from "@web/core/l10n/translation"; import { useService } from "@web/core/utils/hooks"; -const { Component, onWillStart } = owl; +const { Component, onWillStart, onWillUpdateProps } = owl; -export class JsonPpopOver extends Component { - setup() { - this.props = { ...this.props, ...JSON.parse(this.props.value) }; +export class JsonPopOver extends Component { + + setup(){ + this.jsonValue = JSON.parse(this.props.value); + onWillUpdateProps(nextProps => { + this.jsonValue = JSON.parse(nextProps.value); + }); } } -JsonPpopOver.displayName = _lt("Json Popup"); -JsonPpopOver.supportedTypes = ["char"]; +JsonPopOver.displayName = _lt("Json Popup"); +JsonPopOver.supportedTypes = ["char"]; -export class PopOverLeadDays extends JsonPpopOver { +export class PopOverLeadDays extends JsonPopOver { setup() { super.setup(); const user = useService("user"); @@ -39,14 +43,14 @@ export class PopOverLeadDays extends JsonPpopOver { _formatQty(field) { return this.displayUOM - ? `${this.props[field]} ${this.props.product_uom_name}` - : this.props[field]; + ? `${this.jsonValue[field]} ${this.jsonValue.product_uom_name}` + : this.jsonValue[field]; } } -PopOverLeadDays.template = "stock.leadDaysPopOver"; +PopOverLeadDays.template = "stock.leadDays"; -export class ReplenishmentHistoryWidget extends JsonPpopOver {} +export class ReplenishmentHistoryWidget extends JsonPopOver {} ReplenishmentHistoryWidget.template = "stock.replenishmentHistory"; registry.category("fields").add("lead_days_widget", PopOverLeadDays); diff --git a/addons/stock/static/src/widgets/json_widget.xml b/addons/stock/static/src/widgets/json_widget.xml index f64f2568b78..08bf10810fc 100644 --- a/addons/stock/static/src/widgets/json_widget.xml +++ b/addons/stock/static/src/widgets/json_widget.xml @@ -1,29 +1,29 @@ -
+

Lead Times


- The forecasted stock on the - is + The forecasted stock on the + is below the inventory minimum of : should be replenished to reach the maximum of .

- +
- - + @@ -33,9 +33,9 @@

Sales History


-
Today +
Forecasted Date - = + =
+
- +