diff --git a/sao/src/screen.js b/sao/src/screen.js index 5f0fada6d7..7801e51372 100644 --- a/sao/src/screen.js +++ b/sao/src/screen.js @@ -1362,6 +1362,7 @@ return this.__current_record; }, set current_record(record) { + let changed = this.__current_record !== record; this.__current_record = record; var pos = null; var record_id = null; @@ -1377,15 +1378,22 @@ this.record_message( pos || 0, this.group.length + this.offset, this.search_count, record_id); - if (this.switch_callback) { - this.switch_callback(); - } - if (this.has_update_resources()) { - if (record) { - record.get_resources().always( - this.update_resources.bind(this)); - } else { - this.update_resources(); + if (changed) { + for (let window_ of this.windows) { + if (window_.record_changed) { + window_.record_changed(); + } + } + if (this.switch_callback) { + this.switch_callback(); + } + if (this.has_update_resources()) { + if (record) { + record.get_resources().always( + this.update_resources.bind(this)); + } else { + this.update_resources(); + } } } }, diff --git a/sao/src/tab.js b/sao/src/tab.js index 7cf75115db..2fab4a0346 100644 --- a/sao/src/tab.js +++ b/sao/src/tab.js @@ -1611,8 +1611,18 @@ msg = name + '/' + Sao.common.humanize(size); } this.status_label.text(msg).attr('title', msg); - this.info_bar.clear(); this.set_buttons_sensitive(); + }, + record_modified: function() { + this.set_buttons_sensitive(); + this.info_bar.refresh(); + }, + record_saved: function() { + this.set_buttons_sensitive(); + this.refresh_resources(); + }, + record_changed: function() { + this.info_bar.clear(); this.refresh_attachment_preview(); if (this._chat) { @@ -1627,14 +1637,6 @@ this.update_sidebar(); } }, - record_modified: function() { - this.set_buttons_sensitive(); - this.info_bar.refresh(); - }, - record_saved: function() { - this.set_buttons_sensitive(); - this.refresh_resources(); - }, action: function() { window.setTimeout(() => { this.buttons.action.click(); diff --git a/tryton/tryton/gui/window/form.py b/tryton/tryton/gui/window/form.py index 9d3d9684ae..0d2a587d6c 100644 --- a/tryton/tryton/gui/window/form.py +++ b/tryton/tryton/gui/window/form.py @@ -652,19 +652,7 @@ class Form(TabContent): else: msg = "%s/%s" % (name, common.humanize(size)) self.status_label.set_text(msg) - self.info_bar_clear() self.set_buttons_sensitive() - self.refresh_attachment_preview() - if self._chat: - self._chat.unregister() - self.chat.remove(self._chat.widget) - if self.screen.current_reference: - self._chat = Chat(self.screen.current_reference) - self.chat.add(self._chat.widget) - self.chat.show_all() - self._chat.refresh() - else: - self.buttons['chat'].set_active(False) def record_modified(self): def _record_modified(): @@ -679,6 +667,20 @@ class Form(TabContent): self.set_buttons_sensitive() self.refresh_resources() + def record_changed(self): + self.info_bar_clear() + self.refresh_attachment_preview() + if self._chat: + self._chat.unregister() + self.chat.remove(self._chat.widget) + if self.screen.current_reference: + self._chat = Chat(self.screen.current_reference) + self.chat.add(self._chat.widget) + self.chat.show_all() + self._chat.refresh() + else: + self.buttons['chat'].set_active(False) + def modified_save(self): self.screen.save_tree_state() self.screen.current_view.set_value() diff --git a/tryton/tryton/gui/window/view_form/screen/screen.py b/tryton/tryton/gui/window/view_form/screen/screen.py index 109edf6be7..bca7a73fae 100644 --- a/tryton/tryton/gui/window/view_form/screen/screen.py +++ b/tryton/tryton/gui/window/view_form/screen/screen.py @@ -502,6 +502,7 @@ class Screen: return self.__current_record def __set_current_record(self, record): + changed = self.__current_record != record self.__current_record = record if record: try: @@ -514,9 +515,13 @@ class Screen: self.record_message( pos, len(self.group) + self.offset, self.search_count, record and record.id) - self.update_resources(record.resources if record else None) - # update resources after 1 second - GLib.timeout_add(1000, self._update_resources, record) + if changed: + for window in self.windows: + if hasattr(window, 'record_changed'): + window.record_changed() + self.update_resources(record.resources if record else None) + # update resources after 1 second + GLib.timeout_add(1000, self._update_resources, record) current_record = property(__get_current_record, __set_current_record)