Subject: changeset in tryton:4.6 Ensure sort key always return an integer From: Cédric Krier <[email protected]>
changeset 43c922d087b5 in tryton:4.6 details: https://hg.tryton.org/tryton?cmd=changeset;node=43c922d087b5 description: Ensure sort key always return an integer When sorting tree model, it is possible that some ids are not in the ordered list (because they do not fit anymore in the domain). So we return the number of records so they are moved at the end of the list. issue8042 review53531002 (grafted from 74557f917ae5ac2c96d45aa90b21019e54a7db74) diffstat: tryton/gui/window/view_form/view/list.py | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (13 lines): diff -r 7770a911bca2 -r 43c922d087b5 tryton/gui/window/view_form/view/list.py --- a/tryton/gui/window/view_form/view/list.py Sun Feb 03 20:25:03 2019 +0100 +++ b/tryton/gui/window/view_form/view/list.py Sun Feb 03 20:29:09 2019 +0100 @@ -144,7 +144,8 @@ def sort(self, ids): old_idx = {record.id: i for i, record in enumerate(self.group)} new_idx = {id_: i for i, id_ in enumerate(ids)} - self.group.sort(key=lambda r: new_idx.get(r.id)) + size = len(self.group) + self.group.sort(key=lambda r: new_idx.get(r.id, size)) new_order = [] prev = None for record in self.group:
