Ensure field is loaded before applying changes
For fields like xxx2Many the changed values are operation to apply on the existing value. So we must be sure to have loaded the value. issue9730 review314491002
This commit is contained in:
1 parent
45ac695132
commit
ffa00e1f06
1 file changed
+20
-8
+20
-8
@@ -622,11 +622,14 @@
|
||||
is_loaded: function(name) {
|
||||
return ((this.id < 0) || (name in this._loaded));
|
||||
},
|
||||
load: function(name) {
|
||||
load: function(name, async) {
|
||||
var fname;
|
||||
var prm;
|
||||
if (async === undefined) {
|
||||
async = true;
|
||||
}
|
||||
if (this.is_loaded(name)) {
|
||||
return jQuery.when();
|
||||
return async? jQuery.when() : this.model.fields[name];
|
||||
}
|
||||
if (this.group.prm.state() == 'pending') {
|
||||
return this.group.prm.then(function() {
|
||||
@@ -751,9 +754,9 @@
|
||||
context[this.model.name + '.' + fname] = 'size';
|
||||
}
|
||||
}
|
||||
prm = this.model.execute('read', [Object.keys(id2record).map(
|
||||
var result = this.model.execute('read', [Object.keys(id2record).map(
|
||||
function (e) { return parseInt(e, 10); }),
|
||||
fnames_to_fetch], context);
|
||||
fnames_to_fetch], context, async);
|
||||
var succeed = function(values, exception) {
|
||||
if (exception === undefined) exception = false;
|
||||
var id2value = {};
|
||||
@@ -794,8 +797,17 @@
|
||||
}
|
||||
return succeed(failed_values, true);
|
||||
};
|
||||
this.group.prm = prm.then(succeed, failed);
|
||||
return this.group.prm;
|
||||
if (async) {
|
||||
this.group.prm = result.then(succeed, failed);
|
||||
return this.group.prm;
|
||||
} else {
|
||||
if (result) {
|
||||
succeed(result);
|
||||
} else {
|
||||
failed();
|
||||
}
|
||||
return this.model.fields[name];
|
||||
}
|
||||
},
|
||||
set: function(values, validate) {
|
||||
if (validate === undefined) {
|
||||
@@ -1130,7 +1142,7 @@
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
this.model.fields[fieldname].set_on_change(this, result);
|
||||
this.load(fieldname, false).set_on_change(this, result);
|
||||
}
|
||||
},
|
||||
set_on_change: function(values) {
|
||||
@@ -1147,7 +1159,7 @@
|
||||
var related = fieldname + '.';
|
||||
this._values[related] = values[related] || {};
|
||||
}
|
||||
this.model.fields[fieldname].set_on_change(this, value);
|
||||
this.load(fieldname, false).set_on_change(this, value);
|
||||
}
|
||||
},
|
||||
autocomplete_with: function(fieldname) {
|
||||
|
||||
Reference in new issue
Block a user