summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Martinelli <nim@odoo.com>2016-08-16 11:53:49 +0200
committerNicolas Martinelli <nim@odoo.com>2016-08-16 13:09:49 +0200
commitc2fe9fe0e6b7e8d84eabfbdd6f6b69ecd14c4a79 (patch)
treebbc0113d349edb7b645a756ce8f3220ff2b04c15
parent71594f59581450f1e334669311e826f7364d1e86 (diff)
[FIX] web: prevent double-click on statusbar
When double-clicking on the statusbar widget, two calls to write are performed. This can cause unwanted behavior, and when the `write` method takes a lot of time to process, it's not possible to prevent it server-side. Courtesy of @gurneyalex and @aab-odoo Closes #13134 opw-686025 FORWARD-PORT UP TO SAAS-6!
-rw-r--r--addons/web/static/src/js/view_form.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js
index 3c6bd5f1a1a..86697f44903 100644
--- a/addons/web/static/src/js/view_form.js
+++ b/addons/web/static/src/js/view_form.js
@@ -6145,10 +6145,14 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({
return fields;
});
},
- on_click_stage: function (ev) {
+ on_click_stage: _.debounce(function (ev) {
var self = this;
var $li = $(ev.currentTarget);
+ var ul = $li.closest('.oe_form_field_status');
var val;
+ if (ul.attr('disabled')) {
+ return;
+ }
if (this.field.type == "many2one") {
val = parseInt($li.data("id"), 10);
}
@@ -6165,13 +6169,16 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({
this.view.recursive_save().done(function() {
var change = {};
change[self.name] = val;
+ ul.attr('disabled', true);
self.view.dataset.write(self.view.datarecord.id, change).done(function() {
self.view.reload();
+ }).always(function() {
+ ul.removeAttr('disabled');
});
});
}
}
- },
+ }, 300),
});
instance.web.form.FieldMonetary = instance.web.form.FieldFloat.extend({