summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2016-05-17 09:53:36 +0200
committerGéry Debongnie <ged@odoo.com>2016-05-17 10:24:47 +0200
commit95cbee6243af2ff52b03b682c9cd31e50fb11472 (patch)
tree86b68df1755f23010eef9bc0606796cad560821c /addons/web/static/src
parenta5277bc10642bf200a890e6540e968a9a4cb9773 (diff)
[FIX] web: fix duplicate changes in form view
Before this commit, in some cases, clicking on 'save' button, then on other buttons (like 'validate' in invoices) had the unfortunate effect of applying twice the changes in some cases. More specifically the problem appears when: 1. an onchange is triggered (for example, taxes in invoices) 2. the user clicks on 'save', buttons are disabled 3. the 'save' actions is completed, the buttons are enabled, but the on_button_save still does some work: triggering event, and reloading the view 4. the user clicks on 'validate' 5. the onchange completes, this triggers some more work Our only protection against such interactions is right now the fact that buttons are disabled/enabled. In my opinion, there should be a way to guarantee that actions are properly serialized (that is actually what a mutex is for... just saying). But the code of the form view/list view is too coupled, and such changes are quite dangerous. A real refactoring of those is needed at some point in the future.
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/views/form_view.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/addons/web/static/src/js/views/form_view.js b/addons/web/static/src/js/views/form_view.js
index ba181712527..13aae8b2d88 100644
--- a/addons/web/static/src/js/views/form_view.js
+++ b/addons/web/static/src/js/views/form_view.js
@@ -740,12 +740,13 @@ var FormView = View.extend(common.FieldManagerMixin, {
return;
}
this.disable_button();
- return this.save().done(function(result) {
+ return this.save().then(function(result) {
self.trigger("save", result);
- self.reload().then(function() {
+ return self.reload().then(function() {
self.to_view_mode();
core.bus.trigger('do_reload_needaction');
core.bus.trigger('form_view_saved', self);
+ self.enable_button();
});
}).always(function(){
self.enable_button();