Make create call synchronous

This avoid to create multiple times the same record if Record.save is called
multiple times.

issue7148
review44211002
This commit is contained in:
Cédric Krier committed 2018-03-27 10:50:10 +02:00
1 parent 9f80bb9b4f
commit aef87ed37a
1 file changed
+2 -5
+2 -5
View File
@@ -516,11 +516,8 @@
var values = this.get();
if ((this.id < 0) || !jQuery.isEmptyObject(values)) {
if (this.id < 0) {
prm = this.model.execute('create', [[values]], context);
var created = function(ids) {
this.id = ids[0];
};
prm.done(created.bind(this));
// synchronous call to avoid multiple creation
this.id = this.model.execute('create', [[values]], context, false)[0];
} else {
if (!jQuery.isEmptyObject(values)) {
context._timestamp = this.get_timestamp();