From c94900b2dee84d64659c318613f5d6ae6bc7d280 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 --- 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 3189cc9baa..71176e6a6d 100644 --- a/sao/src/view/form.js +++ b/sao/src/view/form.js @@ -5440,7 +5440,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 b500012621..5d094526f6 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 @@ -241,9 +241,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)