[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
This commit is contained in:
Nicolas Martinelli
2017-03-07 11:57:14 +01:00
parent fb35132bc6
commit 4ce309dfab
+5 -3
View File
@@ -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();
});
},