changeset f51305ab6068 in tryton:default
details: https://hg.tryton.org/tryton?cmd=changeset;node=f51305ab6068
description:
        Position copied records based on order

        issue9474
        review311851002
diffstat:

 CHANGELOG                                    |  1 +
 tryton/gui/window/view_form/model/group.py   |  8 ++++++--
 tryton/gui/window/view_form/screen/screen.py |  6 +++---
 3 files changed, 10 insertions(+), 5 deletions(-)

diffs (58 lines):

diff -r fde27352cc9b -r f51305ab6068 CHANGELOG
--- a/CHANGELOG Tue Jul 21 14:43:59 2020 +0200
+++ b/CHANGELOG Sat Jul 25 00:49:32 2020 +0200
@@ -1,3 +1,4 @@
+* Position copied records based on order
 * Allow configuration of default colors for graph and calendar
 * Use existing context for get_preferences
 * Add context to export URL
diff -r fde27352cc9b -r f51305ab6068 tryton/gui/window/view_form/model/group.py
--- a/tryton/gui/window/view_form/model/group.py        Tue Jul 21 14:43:59 
2020 +0200
+++ b/tryton/gui/window/view_form/model/group.py        Sat Jul 25 00:49:32 
2020 +0200
@@ -237,7 +237,7 @@
                 return []
         return list({}.fromkeys(res))
 
-    def load(self, ids, modified=False):
+    def load(self, ids, modified=False, position=-1):
         if not ids:
             return True
 
@@ -249,7 +249,11 @@
             new_record = self.get(id)
             if not new_record:
                 new_record = Record(self.model_name, id, group=self)
-                self.append(new_record)
+                if position == -1:
+                    self.append(new_record)
+                else:
+                    self.insert(position, new_record)
+                    position += 1
                 new_record.signal_connect(self, 'record-changed',
                     self._record_changed)
                 new_record.signal_connect(self, 'record-modified',
diff -r fde27352cc9b -r f51305ab6068 
tryton/gui/window/view_form/screen/screen.py
--- a/tryton/gui/window/view_form/screen/screen.py      Tue Jul 21 14:43:59 
2020 +0200
+++ b/tryton/gui/window/view_form/screen/screen.py      Sat Jul 25 00:49:32 
2020 +0200
@@ -782,7 +782,7 @@
                 context=self.context)
         except RPCException:
             return False
-        self.load(new_ids)
+        self.load(new_ids, position=self.new_position)
         return True
 
     def set_tree_state(self):
@@ -887,10 +887,10 @@
             domain, cls=JSONEncoder, separators=(',', ':'))
         return json_domain
 
-    def load(self, ids, set_cursor=True, modified=False):
+    def load(self, ids, set_cursor=True, modified=False, position=-1):
         self.tree_states.clear()
         self.tree_states_done.clear()
-        self.group.load(ids, modified=modified)
+        self.group.load(ids, modified=modified, position=position)
         self.current_view.reset()
         if ids and self.current_view.view_type != 'calendar':
             self.display(ids[0])

Reply via email to