details: https://code.tryton.org/tryton/commit/04b97e05a510
branch: 7.0
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 (103 lines):
diff -r ce853d2f1ca0 -r 04b97e05a510 sao/src/view/form.js
--- a/sao/src/view/form.js Thu Apr 09 18:24:39 2026 +0200
+++ b/sao/src/view/form.js Thu Apr 16 22:45:15 2026 +0200
@@ -370,7 +370,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];
@@ -382,10 +383,12 @@
field.set_state(record);
}
for (const widget of widgets) {
- widget.display();
+ let prm = widget.display();
+ if (prm) {
+ promesses.push(prm);
+ }
}
}
- var promesses = [];
for (const j in this.state_widgets) {
var state_widget = this.state_widgets[j];
var prm = state_widget.set_state(record);
@@ -398,7 +401,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();
}
@@ -3435,7 +3438,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;
@@ -3445,8 +3448,7 @@
this.screen.new_group();
this.screen.current_record = null;
this.screen.group.parent = null;
- this.screen.display();
- return;
+ return this.screen.display();
}
var new_group = record.field_get_client(this.field_name);
@@ -3475,13 +3477,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() {
@@ -3960,7 +3962,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;
@@ -3968,20 +3970,19 @@
this.screen.new_group();
this.screen.current_record = null;
this.screen.group.parent = null;
- this.screen.display();
- 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() {