Subject: changeset in tryton:4.4 Ensure sort key always return an integer
From: Cédric Krier <[email protected]>

changeset 4b20e5463396 in tryton:4.4
details: https://hg.tryton.org/tryton?cmd=changeset;node=4b20e5463396
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 2eaae4721ee4 -r 4b20e5463396 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
@@ -145,7 +145,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:

Reply via email to