From ae9d57bc1e691f3bb7428c3dc5c0b602031d7a67 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Wed, 4 May 2016 13:14:25 +0200 Subject: [PATCH] [IMP] web: multi-click on save on view form (no fp) When clicking on save several time when editing a view form it can be saved several times which can be an issue for one to many. The normal happenstance when saving should be as follow: -> save (click) -> wait write result -> received write result -> reload the form with updated data and updates buttons But when clicking several time, it could become: -> save (click) -> wait write result -> received write result -> save (click) -> wait write result -> received write result -> reload the form with updated data and updates buttons This commit only reinstate the saving feature once the form is reloaded. related to opw-671793 backport of 8.0's dd714ac note: no need to forward-port --- addons/web/static/src/js/view_form.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index d243c9b1062..84ffd21f9d6 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -726,14 +726,16 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM $(e.target).attr("disabled", true); return this.save().done(function(result) { self.trigger("save", result); - self.reload().then(function() { + self.reload().always(function(){ + $(e.target).attr("disabled", false); + }).then(function() { self.to_view_mode(); var parent = self.ViewManager.ActionManager.getParent(); if(parent){ parent.menu.do_reload_needaction(); } }); - }).always(function(){ + }).fail(function(){ $(e.target).attr("disabled", false); }); },