From 6e322c9553cfbdde1226112cd8afef00fb9ccaa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 30 Jun 2024 01:53:24 +0200 Subject: [PATCH] Do not iterate over MultiSelection value of Dict key if it is null Closes #13375 (grafted from d938889e4f42517b7433685091e6cfce5080063a) --HG-- branch : 6.0 --- sao/src/view/form.js | 4 +++- .../gui/window/view_form/view/form_gtk/dictionary.py | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/sao/src/view/form.js b/sao/src/view/form.js index 523a81c23f..d0c9f4e87a 100644 --- a/sao/src/view/form.js +++ b/sao/src/view/form.js @@ -4940,7 +4940,9 @@ function eval_pyson(value){ return value.map(function(e) { return JSON.parse(e); }); }, set_value: function(value) { - value = value.map(function(e) { return JSON.stringify(e); }); + if (value) { + value = value.map(function(e) { return JSON.stringify(e); }); + } this.input.val(value); } }); diff --git a/tryton/tryton/gui/window/view_form/view/form_gtk/dictionary.py b/tryton/tryton/gui/window/view_form/view/form_gtk/dictionary.py index e21a8d6213..e3f306a885 100644 --- a/tryton/tryton/gui/window/view_form/view/form_gtk/dictionary.py +++ b/tryton/tryton/gui/window/view_form/view/form_gtk/dictionary.py @@ -236,9 +236,10 @@ class DictMultiSelectionEntry(DictEntry): selection.handler_block_by_func(self._changed) try: selection.unselect_all() - for v in value: - if v in value2path: - selection.select_path(value2path[v]) + if value: + for v in value: + if v in value2path: + selection.select_path(value2path[v]) finally: selection.handler_unblock_by_func(self._changed)