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) --HG-- branch : 7.0
This commit is contained in:
+37
-10
@@ -366,11 +366,12 @@ function eval_pyson(value){
|
||||
});
|
||||
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) {
|
||||
@@ -406,7 +407,13 @@ function eval_pyson(value){
|
||||
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;
|
||||
@@ -3355,7 +3362,11 @@ function eval_pyson(value){
|
||||
},
|
||||
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) {
|
||||
@@ -3443,7 +3454,7 @@ function eval_pyson(value){
|
||||
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;
|
||||
@@ -3489,7 +3500,13 @@ function eval_pyson(value){
|
||||
.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) {
|
||||
@@ -3735,7 +3752,11 @@ function eval_pyson(value){
|
||||
}
|
||||
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();
|
||||
@@ -3964,7 +3985,7 @@ function eval_pyson(value){
|
||||
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;
|
||||
|
||||
@@ -3985,7 +4006,13 @@ function eval_pyson(value){
|
||||
.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();
|
||||
|
||||
Reference in New Issue
Block a user