details: https://code.tryton.org/tryton/commit/f8e83739f8d3
branch: 7.8
user: Cédric Krier <[email protected]>
date: Thu Apr 16 22:45:15 2026 +0200
description:
Support widget returning promise on display
The xxx2Many widgets can not be displayed synchronously so we need to
include
there promise in the promise returned by the form view display method.
#14769
(grafted from 3516c75e4f431680161d7d9e6c5d2ccce0186378)
diffstat:
sao/src/view/form.js | 25 +++++++++++++------------
1 files changed, 13 insertions(+), 12 deletions(-)
diffs (105 lines):
diff -r 3b49f78c45de -r f8e83739f8d3 sao/src/view/form.js
--- a/sao/src/view/form.js Wed Apr 15 16:26:20 2026 +0200
+++ b/sao/src/view/form.js Thu Apr 16 22:45:15 2026 +0200
@@ -382,7 +382,8 @@
}
}
return jQuery.when.apply(jQuery,promesses)
- .done(() => {
+ .then(() => {
+ let promesses = [];
var record = this.record;
for (const name in this.widgets) {
var widgets = this.widgets[name];
@@ -394,10 +395,12 @@
field.set_state(record);
}
for (const widget of widgets) {
- widget.display();
+ let prm = widget.display();
+ if (prm) {
+ promesses.push(prm);
+ }
}
}
- var promesses = [];
// We iterate in the reverse order so that the most nested
// widgets are computed first and set_state methods can
rely
// on their children having their state set
@@ -412,7 +415,7 @@
}
// re-set the grid templates for the StateWidget that are
// asynchronous
- jQuery.when.apply(jQuery, promesses).done(() => {
+ return jQuery.when.apply(jQuery, promesses).then(() => {
for (const container of this.containers) {
container.set_grid_template();
}
@@ -3621,7 +3624,7 @@
display: function() {
Sao.View.Form.One2Many._super.display.call(this);
- this.prm.done(() => {
+ return this.prm.then(() => {
this._set_button_sensitive();
var record = this.record;
@@ -3631,9 +3634,8 @@
this.screen.new_group();
this.screen.current_record = null;
this.screen.group.parent = null;
- this.screen.display();
this.screen.screen_container.hide_filter();
- return;
+ return this.screen.display();
}
var new_group = record.field_get_client(this.field_name);
@@ -3662,13 +3664,13 @@
this.screen.domain = domain;
}
this.screen.size_limit = size_limit;
- this.screen.display();
if (this.attributes.height !== undefined) {
this.content
.find('.treeview,.list-form').first()
.css('min-height', this.attributes.height + 'px')
.css('max-height', this.attributes.height + 'px');
}
+ return this.screen.display();
});
},
focus: function() {
@@ -4204,7 +4206,7 @@
display: function() {
Sao.View.Form.Many2Many._super.display.call(this);
- this.prm.done(() => {
+ return this.prm.then(() => {
var record = this.record;
var field = this.field;
@@ -4212,21 +4214,20 @@
this.screen.new_group();
this.screen.current_record = null;
this.screen.group.parent = null;
- this.screen.display();
this.screen.screen_container.hide_filter();
- return;
+ return this.screen.display();
}
var new_group = record.field_get_client(this.field_name);
if (new_group != this.screen.group) {
this.screen.set_group(new_group);
}
- this.screen.display();
if (this.attributes.height !== undefined) {
this.content
.find('.treeview,.list-form').first()
.css('min-height', this.attributes.height + 'px')
.css('max-height', this.attributes.height + 'px');
}
+ return this.screen.display();
});
},
focus: function() {