details: https://code.tryton.org/tryton/commit/3516c75e4f43
branch: default
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
diffstat:
sao/src/view/form.js | 25 +++++++++++++------------
1 files changed, 13 insertions(+), 12 deletions(-)
diffs (105 lines):
diff -r 200ef3ae85b8 -r 3516c75e4f43 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();
}
@@ -3618,7 +3621,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;
@@ -3628,9 +3631,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);
@@ -3659,13 +3661,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() {
@@ -4194,7 +4196,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;
@@ -4202,21 +4204,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() {