From 26f91c429cd5dac112e74793c43b828872a90051 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Mon, 13 Mar 2017 13:51:07 +0100 Subject: [PATCH] [FIX] web: cannot debounce prototype function of Widget The `_onClickStage` method of the `FieldStatus` was debounced. This can be done but not directly on prototype functions because they are shared between each instances (just called with different `this`). This does not produced any bug because there never are two instances of this class which are used at the same time in the web client. The problem is however present when trying to make tests as clicks on different statusbar buttons in two different tests were filtered by the debouncing. --- addons/web/static/src/js/fields/relational_fields.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index 4663c40f755..aec966f438c 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -1178,6 +1178,7 @@ var FieldStatus = AbstractField.extend({ init: function () { this._super.apply(this, arguments); this._setState(); + this._onClickStage = _.debounce(this._onClickStage, 300, true); // TODO maybe not useful anymore ? }, //-------------------------------------------------------------------------- @@ -1246,14 +1247,13 @@ var FieldStatus = AbstractField.extend({ /** * Called when on status stage is clicked -> sets the field value. - * Note: this function is debounced... * * @private * @param {MouseEvent} e */ - _onClickStage: _.debounce(function (e) { + _onClickStage: function (e) { this._setValue($(e.currentTarget).data("value")); - }, 300, true), + }, }); /**