From f47775b039197bc568390aa2cb4209032318f950 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Mon, 24 Apr 2017 17:04:24 +0200 Subject: [PATCH] [FIX] account: don't display alert in some cases Before this commit, in the reconciliation widget, the reconciliation alert (exclamation mark) was displayed, even for amounts less than the total. It does not make sense, so we just hide it in that case. --- .../static/src/js/reconciliation/reconciliation_model.js | 4 ++-- .../src/js/reconciliation/reconciliation_renderer.js | 6 +++++- addons/account/static/tests/reconciliation_tests.js | 9 +++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/addons/account/static/src/js/reconciliation/reconciliation_model.js b/addons/account/static/src/js/reconciliation/reconciliation_model.js index f050ebfa8e5..f1ef79108c2 100644 --- a/addons/account/static/src/js/reconciliation/reconciliation_model.js +++ b/addons/account/static/src/js/reconciliation/reconciliation_model.js @@ -403,10 +403,10 @@ var StatementModel = BasicModel.extend({ togglePartialReconcile: function (handle) { var line = this.getLine(handle); var props = _.filter(line.reconciliation_proposition, {'invalid': false}); - if (props.length !== 1) { + var prop = props[0]; + if (props.length !== 1 || Math.abs(line.st_line.amount) >= Math.abs(prop.amount)) { return $.Deferred().reject(); } - var prop = props[0]; prop.partial_reconcile = !prop.partial_reconcile; if (!prop.partial_reconcile) { return this._computeLine(line); diff --git a/addons/account/static/src/js/reconciliation/reconciliation_renderer.js b/addons/account/static/src/js/reconciliation/reconciliation_renderer.js index c2174fdce7f..311bea5d403 100644 --- a/addons/account/static/src/js/reconciliation/reconciliation_renderer.js +++ b/addons/account/static/src/js/reconciliation/reconciliation_renderer.js @@ -303,7 +303,11 @@ var LineRenderer = Widget.extend(FieldManagerMixin, { .attr("data-content", qweb.render('reconciliation.line.mv_line.details', {'line': line})); } - if ((state.balance.amount !== 0 || line.partial_reconcile) && props.length === 1) { + if ((state.balance.amount !== 0 || line.partial_reconcile) && props.length === 1 && + ( + (state.st_line.amount > 0 && state.st_line.amount < props[0].amount) || + (state.st_line.amount < 0 && state.st_line.amount > props[0].amount)) + ) { var $cell = $line.find(line.amount > 0 ? '.cell_right' : '.cell_left'); var text; if (line.partial_reconcile) { diff --git a/addons/account/static/tests/reconciliation_tests.js b/addons/account/static/tests/reconciliation_tests.js index c9aad72901e..293baaf5480 100644 --- a/addons/account/static/tests/reconciliation_tests.js +++ b/addons/account/static/tests/reconciliation_tests.js @@ -599,7 +599,7 @@ QUnit.module('account', { QUnit.test('Reconciliation partial', function (assert) { - assert.expect(9); + assert.expect(10); var clientAction = new ReconciliationClientAction.StatementAction(null, this.params.options); testUtils.addMockEnvironment(clientAction, { @@ -627,7 +627,12 @@ QUnit.module('account', { clientAction.appendTo($('body')); - var widget = clientAction.widgets[1]; + var widget = clientAction.widgets[0]; + + widget.$('.match .cell_account_code:first').trigger('click'); + assert.notOk( widget.$('.cell_right .line_info_button').length, "should not display the partial reconciliation alert"); + + widget = clientAction.widgets[1]; assert.notOk( widget.$('.cell_left .line_info_button').length, "should not display the partial reconciliation alert"); widget.$('.accounting_view thead td:first').trigger('click');