From aef87ed37a974ebf250f18318b85a413f035df81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 27 Mar 2018 10:50:10 +0200 Subject: [PATCH] Make create call synchronous This avoid to create multiple times the same record if Record.save is called multiple times. issue7148 review44211002 --- src/model.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/model.js b/src/model.js index 8ea7c9692e..d9544befb0 100644 --- a/src/model.js +++ b/src/model.js @@ -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();