mirror of
https://github.com/NaN-tic/sao-base.git
synced 2023-12-14 03:13:01 +01:00
Record.defaut_get must return a promise which resolves with values
The promise doesn't always return the values if there is any autocomplete and the promise is resolved before the set_default is called. So we use our custom deferred that will be resolved after the call to set_default and the autocomplete promises. issue5222 review19721002
This commit is contained in:
parent
a392640988
commit
a0b1d64e44
13
src/model.js
13
src/model.js
|
@ -766,11 +766,12 @@
|
|||
this.model.fields[name].set_client(this, value, force_change);
|
||||
},
|
||||
default_get: function() {
|
||||
var dfd = jQuery.Deferred();
|
||||
var promises = [];
|
||||
if (!jQuery.isEmptyObject(this.model.fields)) {
|
||||
var prm = this.model.execute('default_get',
|
||||
[Object.keys(this.model.fields)], this.get_context());
|
||||
var force_parent = function(values) {
|
||||
prm.then(function(values) {
|
||||
if (this.group.parent &&
|
||||
this.group.parent_name in this.group.model.fields) {
|
||||
var parent_field =
|
||||
|
@ -785,13 +786,11 @@
|
|||
this.group.parent.id;
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}.bind(this);
|
||||
prm = prm.pipe(force_parent).then(function(values) {
|
||||
this.set_default(values);
|
||||
return values;
|
||||
jQuery.when.apply(promises).then(function() {
|
||||
dfd.resolve(values);
|
||||
});
|
||||
}.bind(this));
|
||||
promises.push(prm);
|
||||
}
|
||||
for (var fname in this.model.fields) {
|
||||
var field = this.model.fields[fname];
|
||||
|
@ -800,7 +799,7 @@
|
|||
promises.push(this.do_autocomplete(fname));
|
||||
}
|
||||
}
|
||||
return jQuery.when.apply(promises);
|
||||
return dfd;
|
||||
},
|
||||
set_default: function(values) {
|
||||
var fieldnames = [];
|
||||
|
|
Loading…
Reference in a new issue