summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic
diff options
context:
space:
mode:
authorDavid Monjoie <dmo@odoo.com>2017-05-17 14:33:56 +0200
committerDavid Monjoie <dmo@odoo.com>2017-05-23 11:41:17 +0200
commit374295bf849680e9173475bdf01794f2a1935de3 (patch)
tree1e6825d1d87f8dd83f8702e03192807970534bf4 /addons/web/static/src/js/views/basic
parent3460bda5203ce365bdc56a79ef906217219acb6d (diff)
[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.
Diffstat (limited to 'addons/web/static/src/js/views/basic')
-rw-r--r--addons/web/static/src/js/views/basic/basic_controller.js9
1 files changed, 5 insertions, 4 deletions
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
}