From a61550e1fdead9a40588933218dfefbb57db61ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 15 Mar 2009 23:50:29 +0100 Subject: [PATCH] Force call of on_write after action Use a better reload behavior to group calls --- tryton/gui/window/view_form/model/group.py | 14 ++++++++++---- tryton/gui/window/view_form/screen/screen.py | 4 +++- tryton/gui/window/view_form/view/form.py | 2 +- .../gui/window/view_form/view/form_gtk/parser.py | 2 +- tryton/gui/window/view_form/view/list.py | 2 +- .../gui/window/view_form/view/list_gtk/parser.py | 2 +- 6 files changed, 17 insertions(+), 9 deletions(-) diff --git a/tryton/gui/window/view_form/model/group.py b/tryton/gui/window/view_form/model/group.py index 57b0b3d067..875c85f65a 100644 --- a/tryton/gui/window/view_form/model/group.py +++ b/tryton/gui/window/view_form/model/group.py @@ -109,17 +109,23 @@ class ModelRecordGroup(SignalEvent): saved = model.save() self.writen(saved) - def writen(self, edited_id): - ids = self.on_write_ids([edited_id]) + def writen(self, ids): + if isinstance(ids, (int, long)): + ids = [ids] + ids = self.on_write_ids(ids) if not ids: return self.reload(ids) + return ids def reload(self, ids): + models = [] for obj_id in ids: for model in self.models: - if model.id == obj_id: - model.reload() + if model.id == obj_id and not model.modified: + models.append(model) + for model in models: + model._loaded = False 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 5aec14f144..5469f15917 100644 --- a/tryton/gui/window/view_form/screen/screen.py +++ b/tryton/gui/window/view_form/screen/screen.py @@ -452,9 +452,11 @@ class Screen(SignalEvent): res = True return res - def reload(self): + def reload(self, writen=False): ids = self.sel_ids_get() self.models.reload(ids) + if writen: + self.models.writen(ids) if self.parent: self.parent.reload() self.display() diff --git a/tryton/gui/window/view_form/view/form.py b/tryton/gui/window/view_form/view/form.py index f2f5a78be3..4749d17e94 100644 --- a/tryton/gui/window/view_form/view/form.py +++ b/tryton/gui/window/view_form/view/form.py @@ -182,7 +182,7 @@ class ViewForm(ParserView): } value = Action._exec_action(act, self.window, data, {}) if atype in ('print', 'action'): - self.screen.reload() + self.screen.reload(writen=True) return value def __getitem__(self, name): diff --git a/tryton/gui/window/view_form/view/form_gtk/parser.py b/tryton/gui/window/view_form/view/form_gtk/parser.py index 177845b516..c5e0dd5c90 100644 --- a/tryton/gui/window/view_form/view/form_gtk/parser.py +++ b/tryton/gui/window/view_form/view/form_gtk/parser.py @@ -82,7 +82,7 @@ class Button(object): }, self.form.window, context=ctx) else: raise Exception('Unallowed button type') - self.form.screen.reload() + self.form.screen.reload(writen=True) else: if self.form.screen.form: self.form.screen.form.message_info( diff --git a/tryton/gui/window/view_form/view/list.py b/tryton/gui/window/view_form/view/list.py index 50aece697c..2487870458 100644 --- a/tryton/gui/window/view_form/view/list.py +++ b/tryton/gui/window/view_form/view/list.py @@ -277,7 +277,7 @@ class ViewList(ParserView): 'ids': obj_ids, } value = Action._exec_action(act, self.window, data, {}) - self.screen.reload() + self.screen.reload(writen=True) return value diff --git a/tryton/gui/window/view_form/view/list_gtk/parser.py b/tryton/gui/window/view_form/view/list_gtk/parser.py index f8e53b13a0..556c0f68fd 100644 --- a/tryton/gui/window/view_form/view/list_gtk/parser.py +++ b/tryton/gui/window/view_form/view/list_gtk/parser.py @@ -866,7 +866,7 @@ class Button(object): }, self.window, context=ctx) else: raise Exception('Unallowed button type') - self.screen.reload() + self.screen.reload(writen=True) else: if self.screen.form: self.screen.form.message_info(