diff --git a/CHANGELOG b/CHANGELOG index 8154a3c2d0..784296c54b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 --git a/tryton/gui/window/view_form/model/group.py b/tryton/gui/window/view_form/model/group.py index 7602cb47a4..379ecd4f2d 100644 --- a/tryton/gui/window/view_form/model/group.py +++ b/tryton/gui/window/view_form/model/group.py @@ -237,7 +237,7 @@ class Group(SignalEvent, list): 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 @@ class Group(SignalEvent, list): 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 --git a/tryton/gui/window/view_form/screen/screen.py b/tryton/gui/window/view_form/screen/screen.py index 1c5916f813..28bc1de3c1 100644 --- a/tryton/gui/window/view_form/screen/screen.py +++ b/tryton/gui/window/view_form/screen/screen.py @@ -782,7 +782,7 @@ class Screen(SignalEvent): 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 @@ class Screen(SignalEvent): 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])