From 15a202c9768b5f7d7c7d7f5a3473e89ba9fa7f01 Mon Sep 17 00:00:00 2001 From: "Hubert Van de Walle (huvw)" Date: Wed, 29 Mar 2023 14:58:24 +0000 Subject: [PATCH] [FIX] stock: PopoverWidgetField json parsing error without value Steps to reproduce ================== - Access a company with no records in transfer model (IT Company, SE Company, etc.) - Go to transfers menu - Click Studio - Click form view button - Click view tab on the left - Click Show invisible elements - Error "The requested change caused an error in the view. It could be because a field was deleted, but still used somewhere else" Cause of the issue ================== Since we are not editing an existing record, the PopoverWidgetField component is loaded without a field value (it is an empty string). This means that JSON.parse will fail opw-3249161 closes odoo/odoo#117148 X-original-commit: ddb36467b401ec401b813182d172f5aab329baa7 Signed-off-by: Tiffany Chang Signed-off-by: Hubert Van De Walle --- addons/stock/static/src/widgets/popover_widget.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock/static/src/widgets/popover_widget.js b/addons/stock/static/src/widgets/popover_widget.js index 3ab687f6623..6d9c1ee88e0 100644 --- a/addons/stock/static/src/widgets/popover_widget.js +++ b/addons/stock/static/src/widgets/popover_widget.js @@ -29,7 +29,7 @@ export class PopoverWidgetField extends Component { this.popover = usePopover(); this.closePopover = null; let fieldValue = this.props.record.data[this.props.name]; - this.jsonValue = JSON.parse(fieldValue); + this.jsonValue = JSON.parse(fieldValue || "{}"); this.color = this.jsonValue.color || 'text-primary'; this.icon = this.jsonValue.icon || 'fa-info-circle'; }