From c2fe9fe0e6b7e8d84eabfbdd6f6b69ecd14c4a79 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 16 Aug 2016 11:53:49 +0200 Subject: [PATCH] [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! --- addons/web/static/src/js/view_form.js | 11 +++++++++-- 1 file 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({