From 848a1b970bd493363b29883c0c20c55c820d04ee Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Mon, 29 Apr 2019 14:44:30 +0000 Subject: [PATCH] [FIX] account: multi-click in reconciliation - Open the bank reconciliation widget - Throttle the connection - Click multiple times on the same move line in order to select it The line is added multiple times to the statement line. We mitigate the behavior thanks to a `debounce`. Fixes #33000 opw-1978551 closes odoo/odoo#33020 Signed-off-by: Nicolas Martinelli (nim) --- .../src/js/reconciliation/reconciliation_renderer.js | 6 ++++++ addons/account/static/tests/reconciliation_tests.js | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/addons/account/static/src/js/reconciliation/reconciliation_renderer.js b/addons/account/static/src/js/reconciliation/reconciliation_renderer.js index c9635c02abc..426c27f223b 100644 --- a/addons/account/static/src/js/reconciliation/reconciliation_renderer.js +++ b/addons/account/static/src/js/reconciliation/reconciliation_renderer.js @@ -271,6 +271,7 @@ var LineRenderer = Widget.extend(FieldManagerMixin, { 'field_changed': '_onFieldChanged', }), _avoidFieldUpdate: {}, + MV_LINE_DEBOUNCE: 200, /** * create partner_id field in editable mode @@ -283,6 +284,11 @@ var LineRenderer = Widget.extend(FieldManagerMixin, { this.model = model; this._initialState = state; + if (this.MV_LINE_DEBOUNCE) { + this._onSelectMoveLine = _.debounce(this._onSelectMoveLine, this.MV_LINE_DEBOUNCE, true); + } else { + this._onSelectMoveLine = this._onSelectMoveLine; + } }, /** diff --git a/addons/account/static/tests/reconciliation_tests.js b/addons/account/static/tests/reconciliation_tests.js index 1475a5cc308..f0141b8772b 100644 --- a/addons/account/static/tests/reconciliation_tests.js +++ b/addons/account/static/tests/reconciliation_tests.js @@ -585,6 +585,7 @@ odoo.define('account.reconciliation_tests', function (require) { "use strict"; var ReconciliationClientAction = require('account.ReconciliationClientAction'); +var ReconciliationRenderer = require('account.ReconciliationRenderer'); var demoData = require('account.reconciliation_tests.data'); var testUtils = require('web.test_utils'); @@ -592,7 +593,13 @@ var testUtils = require('web.test_utils'); QUnit.module('account', { beforeEach: function () { this.params = demoData.getParams(); - } + testUtils.patch(ReconciliationRenderer.LineRenderer, { + MV_LINE_DEBOUNCE: 0, + }); + }, + afterEach: function () { + testUtils.unpatch(ReconciliationRenderer.LineRenderer); + }, }, function () { QUnit.module('Reconciliation');