From 86fec51e17004a32f64b60bfc2daa34c6986007c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 5 Feb 2008 23:19:25 +0100 Subject: [PATCH] Force refresh attachment after editing attachment --- tryton/gui/window/form.py | 3 +++ tryton/gui/window/view_form/model/record.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tryton/gui/window/form.py b/tryton/gui/window/form.py index f20c307de4..528148e0d8 100644 --- a/tryton/gui/window/form.py +++ b/tryton/gui/window/form.py @@ -171,6 +171,9 @@ class Form(SignalEvent): if obj_id: win = Attachment(self.model, obj_id, self.window) win.run() + value = self.screen.current_model + attachment_count = value.get_attachment_count(reload=True) + self.signal('attachment-count', attachment_count) else: self.message_state(_('No resource selected!')) return True diff --git a/tryton/gui/window/view_form/model/record.py b/tryton/gui/window/view_form/model/record.py index a42c22972b..356bb838f5 100644 --- a/tryton/gui/window/view_form/model/record.py +++ b/tryton/gui/window/view_form/model/record.py @@ -239,10 +239,10 @@ class ModelRecord(SignalEvent): self.set_default(ir_default.get_default(self.resource, field_name + '=' + str(value), ctx)) - def get_attachment_count(self): + def get_attachment_count(self, reload=False): if not self.id: return 0 - if self.attachment_count < 0: + if self.attachment_count < 0 or reload: ir_attachment = RPCProxy('ir.attachment') self.attachment_count = ir_attachment.search_count([ ('res_model', '=', self.resource),