changeset d3b83d15ef73 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset&node=d3b83d15ef73
description:
Use tuple in Dict value instead of list
issue10715
review371771002
diffstat:
CHANGELOG | 1 +
trytond/model/fields/dict.py | 3 +++
trytond/tests/test_field_dict.py | 2 +-
3 files changed, 5 insertions(+), 1 deletions(-)
diffs (33 lines):
diff -r 147e6bcfee80 -r d3b83d15ef73 CHANGELOG
--- a/CHANGELOG Thu Sep 23 10:13:09 2021 +0200
+++ b/CHANGELOG Thu Sep 23 10:15:16 2021 +0200
@@ -1,3 +1,4 @@
+* Use tuple in Dict value instead of list
* Do not set record name on title of report get_email
* Add node to id of status
* Use ImmutableDict for Transaction context
diff -r 147e6bcfee80 -r d3b83d15ef73 trytond/model/fields/dict.py
--- a/trytond/model/fields/dict.py Thu Sep 23 10:13:09 2021 +0200
+++ b/trytond/model/fields/dict.py Thu Sep 23 10:15:16 2021 +0200
@@ -42,6 +42,9 @@
# If stored as JSON conversion is done on backend
if isinstance(data, str):
data = json.loads(data, object_hook=JSONDecoder())
+ for key, val in data.items():
+ if isinstance(val, list):
+ data[key] = tuple(val)
dicts[value['id']] = ImmutableDict(data)
return dicts
diff -r 147e6bcfee80 -r d3b83d15ef73 trytond/tests/test_field_dict.py
--- a/trytond/tests/test_field_dict.py Thu Sep 23 10:13:09 2021 +0200
+++ b/trytond/tests/test_field_dict.py Thu Sep 23 10:15:16 2021 +0200
@@ -150,7 +150,7 @@
'dico': {'countries': ['fr', 'be']},
}])
- self.assertDictEqual(dict_.dico, {'countries': ['be', 'fr']})
+ self.assertDictEqual(dict_.dico, {'countries': ('be', 'fr')})
@with_transaction()
def test_invalid_selection_schema(self):