From e49c9f952b67f279a6eecbdfbcdedc95bb7207ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 18 Mar 2008 13:11:26 +0100 Subject: [PATCH] Don't add new record from on_write function --- tryton/gui/window/view_form/model/group.py | 12 ++---------- tryton/gui/window/view_form/screen/screen.py | 4 ++-- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/tryton/gui/window/view_form/model/group.py b/tryton/gui/window/view_form/model/group.py index 0ff3df186b..544d93e2d3 100644 --- a/tryton/gui/window/view_form/model/group.py +++ b/tryton/gui/window/view_form/model/group.py @@ -102,23 +102,15 @@ class ModelRecordGroup(SignalEvent): ids = self.on_write_ids([edited_id]) if not ids: return - index = self.models.index(self[edited_id]) - self.reload(ids, index) + self.reload(ids) - def reload(self, ids, index): + def reload(self, ids): for obj_id in ids: cont = False for model in self.models: if model.id == obj_id: cont = True model.reload() - if cont: - continue - newmod = ModelRecord(self.resource, obj_id, self.window, - parent=self.parent, group=self) - newmod.reload() - new_index = min(index, len(self.models)-1) - self.model_add(newmod, new_index) def on_write_ids(self, ids): if not self.on_write: diff --git a/tryton/gui/window/view_form/screen/screen.py b/tryton/gui/window/view_form/screen/screen.py index d5f4c367c5..4356c02d8b 100644 --- a/tryton/gui/window/view_form/screen/screen.py +++ b/tryton/gui/window/view_form/screen/screen.py @@ -433,7 +433,7 @@ class Screen(SignalEvent): else: self.current_model = None if reload_ids: - self.models.reload(reload_ids, idx) + self.models.reload(reload_ids) self.display() self.current_view.set_cursor() res = obj_id @@ -455,7 +455,7 @@ class Screen(SignalEvent): self.models.remove(model) self.current_model = None if reload_ids: - self.models.reload(reload_ids, 0) + self.models.reload(reload_ids) self.display() self.current_view.set_cursor() res = ids