Return rejected promise when creation fails

issue8168
review51631002
This commit is contained in:
Sergi Almacellas Abellana committed 2019-05-01 21:58:01 +02:00
1 parent dd917e40d4
commit 4bd86b26ec
2 files changed
+8 -9

No files matched your search

+6 -1
View File
@@ -513,7 +513,12 @@
if ((this.id < 0) || !jQuery.isEmptyObject(values)) {
if (this.id < 0) {
// synchronous call to avoid multiple creation
this.id = this.model.execute('create', [[values]], context, false)[0];
try {
this.id = this.model.execute(
'create', [[values]], context, false)[0];
} catch (e) {
return jQuery.Deferred().reject(e);
}
} else {
if (!jQuery.isEmptyObject(values)) {
context._timestamp = this.get_timestamp();
+2 -8
View File
@@ -1437,8 +1437,7 @@
}
}.bind(this));
}
var dfd = jQuery.Deferred();
prm.then(function(current_record) {
return prm.then(function(current_record) {
if (path && current_record && current_record.id) {
path.splice(-1, 1,
[path[path.length - 1][0], current_record.id]);
@@ -1446,12 +1445,7 @@
return this.group.get_by_path(path).then(function(record) {
this.current_record = record;
}.bind(this));
}.bind(this)).then(function() {
this.display().always(dfd.resolve);
}.bind(this), function() {
this.display().always(dfd.reject);
}.bind(this));
return dfd.promise();
}.bind(this)).always(this.display.bind(this));
},
set_cursor: function(new_, reset_view) {
if (!this.current_view) {