details: https://code.tryton.org/tryton/commit/aa6b291b30e9
branch: 7.0
user: Cédric Krier <[email protected]>
date: Fri Aug 14 12:55:53 2026 +0200
description:
Add record changed callback
Only when the current record has changed that those objects needs to be
refreshed/cleared:
- the info bar
- the resources
- the attachment preview
- the chat
Closes #15012
(grafted from dc3a3e20006329b742e6f989a0fd01d485ec80b1)
diffstat:
sao/src/screen.js | 26 +++++++++++++-------
sao/src/tab.js | 6 +++-
tryton/tryton/gui/window/form.py | 6 +++-
tryton/tryton/gui/window/view_form/screen/screen.py | 11 ++++++--
4 files changed, 33 insertions(+), 16 deletions(-)
diffs (119 lines):
diff -r 3436660ee1bc -r aa6b291b30e9 sao/src/screen.js
--- a/sao/src/screen.js Mon Aug 17 17:32:55 2026 +0200
+++ b/sao/src/screen.js Fri Aug 14 12:55:53 2026 +0200
@@ -1311,6 +1311,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;
@@ -1326,15 +1327,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 -r 3436660ee1bc -r aa6b291b30e9 sao/src/tab.js
--- a/sao/src/tab.js Mon Aug 17 17:32:55 2026 +0200
+++ b/sao/src/tab.js Fri Aug 14 12:55:53 2026 +0200
@@ -1517,9 +1517,7 @@
msg = name + '/' + Sao.common.humanize(size);
}
this.status_label.text(msg).attr('title', msg);
- this.info_bar.clear();
this.set_buttons_sensitive();
- this.refresh_attachment_preview();
},
record_modified: function() {
this.set_buttons_sensitive();
@@ -1529,6 +1527,10 @@
this.set_buttons_sensitive();
this.refresh_resources();
},
+ record_changed: function() {
+ this.info_bar.clear();
+ this.refresh_attachment_preview();
+ },
action: function() {
window.setTimeout(() => {
this.buttons.action.click();
diff -r 3436660ee1bc -r aa6b291b30e9 tryton/tryton/gui/window/form.py
--- a/tryton/tryton/gui/window/form.py Mon Aug 17 17:32:55 2026 +0200
+++ b/tryton/tryton/gui/window/form.py Fri Aug 14 12:55:53 2026 +0200
@@ -615,9 +615,7 @@
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()
def record_modified(self):
def _record_modified():
@@ -632,6 +630,10 @@
self.set_buttons_sensitive()
self.refresh_resources()
+ def record_changed(self):
+ self.info_bar_clear()
+ self.refresh_attachment_preview()
+
def modified_save(self):
self.screen.save_tree_state()
self.screen.current_view.set_value()
diff -r 3436660ee1bc -r aa6b291b30e9
tryton/tryton/gui/window/view_form/screen/screen.py
--- a/tryton/tryton/gui/window/view_form/screen/screen.py Mon Aug 17
17:32:55 2026 +0200
+++ b/tryton/tryton/gui/window/view_form/screen/screen.py Fri Aug 14
12:55:53 2026 +0200
@@ -484,6 +484,7 @@
return self.__current_record
def __set_current_record(self, record):
+ changed = self.__current_record != record
self.__current_record = record
if record:
try:
@@ -496,9 +497,13 @@
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)