details: https://code.tryton.org/tryton/commit/bc049d1f5adf
branch: 7.8
user: Adrià Tarroja Caubet <[email protected]>
date: Tue Sep 29 15:31:30 2026 +0200
description:
Set Selection value synchronously when available
Restore the displayed value before Window.Form reads the widgets.
Otherwise
rebuilding the selection may temporarily select its first option.
Closes #15117
(grafted from 0fdec92fe79648f3044c5bc10c4dd729a74028fd)
diffstat:
sao/src/view/form.js | 31 +++++++++++++++----------------
1 files changed, 15 insertions(+), 16 deletions(-)
diffs (53 lines):
diff -r d192197b7e18 -r bc049d1f5adf sao/src/view/form.js
--- a/sao/src/view/form.js Thu Sep 03 15:28:26 2026 +0200
+++ b/sao/src/view/form.js Tue Sep 29 15:31:30 2026 +0200
@@ -2315,34 +2315,33 @@
return;
}
var value = field.get(record);
- var prm, found = false;
+ var found = false;
for (const option of selection) {
if (option[0] === value) {
found = true;
break;
}
}
- if (!found) {
- prm = Sao.common.selection_mixin.get_inactive_selection
- .call(this, value);
- prm = prm.then(inactive => {
- this.select.append(jQuery('<option/>', {
- value: JSON.stringify(inactive[0]),
- text: inactive[1],
- disabled: true
- }));
- });
- } else {
- prm = jQuery.when();
- }
- return prm.then(() => {
+ let set_value = () => {
this.select.val(JSON.stringify(value));
var title = help[value] || null;
if (this.attributes.help && title) {
title = this.attributes.help + '\n' + title;
}
this.select.attr('title', title);
- });
+ };
+ if (!found) {
+ return Sao.common.selection_mixin.get_inactive_selection
+ .call(this, value)
+ .then(inactive => {
+ this.select.append(jQuery('<option/>', {
+ value: JSON.stringify(inactive[0]),
+ text: inactive[1],
+ disabled: true
+ }));
+ }).then(set_value);
+ }
+ set_value();
});
},
display: function() {