From 4ce309dfabc173183c8102080192366d154fa239 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 7 Mar 2017 11:57:14 +0100 Subject: [PATCH] [FIX] web: deactivate buttons To reproduce: - Get a slow connection, e.g. activate throttling in debug mode of the browser. - Create an invoice with at least one tax. - Change a price unit. - Click on 'Save' then repeatedly on 'Validate' The tax lines are duplicated. The issue comes from two identical `write` calls whose purpose is to delete the existing tax line and create a new tax line. The two calls are issued by the click on 'Save' and the click on 'Validate', which triggers a 'Save' since it doesn't consider the form as being saved yet. There were several issues: - The buttons from the statusbar were not disabled - The buttons were enabled too soon. They should be enabled again when the form is reloaded, otherwise the call to 'Validate' doesn't consider the form saved. This is an extension of commit https://github.com/odoo/odoo/commit/bbbf3db581b5cf883 opw-710642 --- addons/web/static/src/js/views/form_view.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/js/views/form_view.js b/addons/web/static/src/js/views/form_view.js index 27753aab766..76f9cae7fdd 100644 --- a/addons/web/static/src/js/views/form_view.js +++ b/addons/web/static/src/js/views/form_view.js @@ -728,11 +728,11 @@ var FormView = View.extend(common.FieldManagerMixin, { } }, disable_button: function () { - this.$('.oe_form_buttons').add(this.$buttons).find('button').addClass('o_disabled').prop('disabled', true); + this.$('.oe_form_buttons,.o_statusbar_buttons').add(this.$buttons).find('button').addClass('o_disabled').prop('disabled', true); this.is_disabled = true; }, enable_button: function () { - this.$('.oe_form_buttons').add(this.$buttons).find('button.o_disabled').removeClass('o_disabled').prop('disabled', false); + this.$('.oe_form_buttons,.o_statusbar_buttons').add(this.$buttons).find('button.o_disabled').removeClass('o_disabled').prop('disabled', false); this.is_disabled = false; }, on_button_save: function(e) { @@ -747,8 +747,10 @@ var FormView = View.extend(common.FieldManagerMixin, { self.to_view_mode(); core.bus.trigger('do_reload_needaction'); core.bus.trigger('form_view_saved', self); + }).always(function() { + self.enable_button(); }); - }).always(function(){ + }).fail(function(){ self.enable_button(); }); },