Allow customizing Dict keys order

We add a sequence attribute to the key definition and use it for sorting.
This attribute is filled by the field sequence if it exists (using
sequence_ordered) or by the key name.

issue8373
review275431002
This commit is contained in:
Cédric Krier committed 2019-06-16 19:24:15 +02:00
1 parent e153034941
commit 70ff820e66
2 files changed
+11 -3

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
* Order Dict keys by sequence
* Support relation fields in domain parser
* Add Dict widget for tree view
* Add handle to reordable line of tree views
@@ -473,9 +473,16 @@ class DictWidget(Widget):
if new_key_names:
self.field.add_keys(list(new_key_names), self.record)
decoder = PYSONDecoder()
for key, val in sorted(value.items()):
if key not in self.field.keys:
continue
def filter_func(item):
key, value = item
return key in self.field.keys
def key(item):
key, value = item
return self.field.keys[key]['sequence'] or 0
for key, val in sorted(filter(filter_func, value.items()), key=key):
if key not in self.fields:
self.add_line(key)
widget = self.fields[key]