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