Make save call synchronous
This avoid to trigger multiple save in parallel which may raise a concurrency exception. Closes #13848
This commit is contained in:
1 parent
d7ccb1b604
commit
96de1ae302
1 file changed
+20
-21
+20
-21
@@ -602,38 +602,37 @@
|
||||
var prm = jQuery.when();
|
||||
if ((this.id < 0) || this.modified) {
|
||||
var values = this.get();
|
||||
if (this.id < 0) {
|
||||
// synchronous call to avoid multiple creation
|
||||
try {
|
||||
try {
|
||||
// synchronous call to avoid multiple creation or save
|
||||
if (this.id < 0) {
|
||||
this.id = this.model.execute(
|
||||
'create', [[values]], context, false)[0];
|
||||
} catch (e) {
|
||||
if (e.promise) {
|
||||
return e.then(() => this.save(force_reload));
|
||||
} else {
|
||||
return jQuery.Deferred().reject();
|
||||
|
||||
} else {
|
||||
if (!jQuery.isEmptyObject(values)) {
|
||||
context._timestamp = this.get_timestamp();
|
||||
this.model.execute(
|
||||
'write', [[this.id], values], context, false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!jQuery.isEmptyObject(values)) {
|
||||
context._timestamp = this.get_timestamp();
|
||||
prm = this.model.execute('write', [[this.id], values],
|
||||
context);
|
||||
} catch (e) {
|
||||
if (e.promise) {
|
||||
return e.then(() => this.save(force_reload));
|
||||
} else {
|
||||
return jQuery.Deferred().reject();
|
||||
}
|
||||
}
|
||||
prm = prm.done(() => {
|
||||
this.cancel();
|
||||
if (force_reload) {
|
||||
return this.reload();
|
||||
}
|
||||
});
|
||||
this.cancel();
|
||||
if (force_reload) {
|
||||
return this.reload();
|
||||
}
|
||||
if (this.group) {
|
||||
prm = prm.done(() => this.group.written(this.id));
|
||||
prm = prm.then(() => this.group.written(this.id));
|
||||
}
|
||||
}
|
||||
if (this.group.parent) {
|
||||
delete this.group.parent.modified_fields[this.group.child_name];
|
||||
prm = prm.done(() => this.group.parent.save(force_reload));
|
||||
prm = prm.then(() => this.group.parent.save(force_reload));
|
||||
}
|
||||
return prm;
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user