From 374295bf849680e9173475bdf01794f2a1935de3 Mon Sep 17 00:00:00 2001 From: David Monjoie Date: Wed, 17 May 2017 14:33:56 +0200 Subject: [FIX] web: save should not re-read fields if none were changed Previously, it used to reload its data when the user clicked multiple times on save, even though there were only changed fields during the first initial save, all the other queued ones have no changes at all and, as such, should not trigger additional reloads. --- addons/web/static/src/js/views/basic/basic_controller.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'addons/web/static/src/js/views/basic/basic_controller.js') diff --git a/addons/web/static/src/js/views/basic/basic_controller.js b/addons/web/static/src/js/views/basic/basic_controller.js index 8d35e7f8fcd..f58b858db9e 100644 --- a/addons/web/static/src/js/views/basic/basic_controller.js +++ b/addons/web/static/src/js/views/basic/basic_controller.js @@ -388,18 +388,19 @@ var BasicController = AbstractController.extend(FieldManagerMixin, { // Note: it is the model's job to do nothing if there is nothing to save if (this.canBeSaved(recordID)) { var self = this; - var def = this.model.save(recordID, { // Save then leave edit mode + var saveDef = this.model.save(recordID, { // Save then leave edit mode reload: options.reload, savePoint: options.savePoint, }); if (!options.stayInEdit) { - def = def.then(function (fieldNames) { - return self._confirmSave(recordID).then(function () { + saveDef = saveDef.then(function (fieldNames) { + var def = fieldNames.length ? self._confirmSave(recordID) : self._setMode('readonly'); + return def.then(function () { return fieldNames; }); }); } - return def; + return saveDef; } else { return $.Deferred().reject(); // Cannot be saved } -- cgit v1.2.3