From 56e386a57742b2066206cb9179673b68366fc37d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 25 Nov 2009 13:13:45 +0100 Subject: [PATCH] Update attachment count when switching tabs for issue1317 (transplanted from dd5fc5447dc8351b228cbbec4b613d33cc1e3c19) --- tryton/gui/main.py | 5 ++++- tryton/gui/window/form.py | 12 +++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/tryton/gui/main.py b/tryton/gui/main.py index 78e8f4bbe1..709f99c70d 100644 --- a/tryton/gui/main.py +++ b/tryton/gui/main.py @@ -1352,7 +1352,10 @@ class Main(object): if self.buttons[i]: self.buttons[i].set_sensitive( bool(view and (i in view.handlers))) - self.buttons['but_attach'].set_stock_id('tryton-attachment') + if hasattr(view, 'update_attachment_count'): + view.update_attachment_count() + else: + self._attachment_count(view, 0) def _attachment_count(self, widget, signal_data): label = _('Attachment(%d)') % signal_data diff --git a/tryton/gui/window/form.py b/tryton/gui/window/form.py index bcf17418c6..e2a817778e 100644 --- a/tryton/gui/window/form.py +++ b/tryton/gui/window/form.py @@ -222,13 +222,19 @@ class Form(SignalEvent): if obj_id >= 0: 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_info(_('No record selected!')) + self.update_attachment_count(reload=True) return True + def update_attachment_count(self, reload=False): + value = self.screen.current_model + if value: + attachment_count = value.get_attachment_count(reload=reload) + else: + attachment_count = 0 + self.signal('attachment-count', attachment_count) + def sig_switch(self, widget=None): if not self.modified_save(): return