From 2f838171ecdfec677baafe9daebed52123c26934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 17 Jul 2015 18:01:48 +0200 Subject: [PATCH] Add force_reload on save and return reload promesse --- src/model.js | 11 ++++++++--- src/screen.js | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/model.js b/src/model.js index 4c9ebd3cdd..fd81a475ef 100644 --- a/src/model.js +++ b/src/model.js @@ -424,7 +424,10 @@ has_changed: function() { return !jQuery.isEmptyObject(this._changed); }, - save: function() { + save: function(force_reload) { + if (force_reload === undefined) { + force_reload = false; + } var context = this.get_context(); var prm = jQuery.when(); var values = this.get(); @@ -443,7 +446,9 @@ } prm.done(function() { this.cancel(); - this.reload(); + if (force_reload) { + return this.reload(); + } }.bind(this)); if (this.group) { this.group.written(this.id); @@ -451,7 +456,7 @@ if (this.group.parent) { delete this.group.parent._changed[this.group.child_name]; prm = prm.done(function() { - return this.group.parent.save(); + return this.group.parent.save(force_reload); }.bind(this)); } return prm; diff --git a/src/screen.js b/src/screen.js index 1382f1cd50..7ef5004b5e 100644 --- a/src/screen.js +++ b/src/screen.js @@ -997,7 +997,7 @@ if (delete_) { records.forEach(function(record) { if (record.group.parent) { - prms.push(record.group.parent.save()); + prms.push(record.group.parent.save(false)); } if (~record.group.record_deleted.indexOf(record)) { record.group.record_deleted.splice( @@ -1307,7 +1307,7 @@ record = selected_records[i]; jQuery.extend(context, record.get_timestamp()); } - record.save().done(function() { + record.save(false).done(function() { record.model.execute(attributes.name, [ids], context).then(process_action.bind(this)) .then(reload_ids);