details: https://code.tryton.org/tryton/commit/f0ca2088f405
branch: 7.8
user: Cédric Krier <[email protected]>
date: Wed May 20 18:50:58 2026 +0200
description:
Make display synchronous when possible
In order to ensure that after the focus out of a field that triggers
on_change's, the view is fully displayed before the set_value call from
the
Window.Form response. Otherwise the set_value restore the previous
value.
Closes #14853
(grafted from fd5d15e75c92282fcadee930c6b51cb02397bbb6)
diffstat:
sao/src/view/form.js | 47 +++++++++++++++++++++++++++++++++++++----------
1 files changed, 37 insertions(+), 10 deletions(-)
diffs (108 lines):
diff -r 446e8bb95266 -r f0ca2088f405 sao/src/view/form.js
--- a/sao/src/view/form.js Sat Jun 06 11:47:25 2026 +0200
+++ b/sao/src/view/form.js Wed May 20 18:50:58 2026 +0200
@@ -378,11 +378,12 @@
});
for (const e of fields) {
const name = e[0];
- promesses.push(record.load(name));
+ if (!record.is_loaded(name)) {
+ promesses.push(record.load(name));
+ }
}
}
- return jQuery.when.apply(jQuery,promesses)
- .then(() => {
+ let display = function() {
let promesses = [];
var record = this.record;
for (const name in this.widgets) {
@@ -420,7 +421,13 @@
container.set_grid_template();
}
});
- });
+ }.bind(this);
+ if (promesses.length) {
+ return jQuery.when.apply(jQuery, promesses).then(
+ () => display());
+ } else {
+ return display();
+ }
},
set_value: function() {
var record = this.record;
@@ -3516,7 +3523,11 @@
},
set_readonly: function(readonly) {
Sao.View.Form.One2Many._super.set_readonly.call(this, readonly);
- this.prm.done(() => this._set_button_sensitive());
+ if (this.prm.state() == 'pending') {
+ this.prm.done(() => this._set_button_sensitive());
+ } else {
+ this._set_button_sensitive();
+ }
this._set_label_state();
},
set_required: function(required) {
@@ -3629,7 +3640,7 @@
display: function() {
Sao.View.Form.One2Many._super.display.call(this);
- return this.prm.then(() => {
+ let display = function() {
this._set_button_sensitive();
var record = this.record;
@@ -3676,7 +3687,13 @@
.css('max-height', this.attributes.height + 'px');
}
return this.screen.display();
- });
+ }.bind(this);
+
+ if (this.prm.state() == 'pending') {
+ return this.prm.then(() => display());
+ } else {
+ return display();
+ }
},
focus: function() {
if (this.attributes.add_remove) {
@@ -3953,7 +3970,11 @@
}
var message = name + ' / ' + Sao.common.humanize(size);
this.label.text(message).attr('title', message);
- this.prm.done(() => this._set_button_sensitive());
+ if (this.prm.state() == 'pending') {
+ this.prm.done(() => this._set_button_sensitive());
+ } else {
+ this._set_button_sensitive();
+ }
},
validate: function() {
var prm = jQuery.Deferred();
@@ -4208,7 +4229,7 @@
display: function() {
Sao.View.Form.Many2Many._super.display.call(this);
- return this.prm.then(() => {
+ let display = function() {
var record = this.record;
var field = this.field;
@@ -4230,7 +4251,13 @@
.css('max-height', this.attributes.height + 'px');
}
return this.screen.display();
- });
+ }.bind(this);
+
+ if (this.prm.state() == 'pending') {
+ return this.prm.then(() => display());
+ } else {
+ return display();
+ }
},
focus: function() {
this.entry.focus();