From aa7bc410f01ffdbe2ff1d1dbb82f8daa194358e4 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Fri, 20 Jul 2018 15:46:16 +0200 Subject: [PATCH] [FIX] account: reconciliation widget: empty line should open write off In manual reconciliation, have an accound with no direct proposal. An empty line should be present Click on it Before this commit, there was a traceback After this commit, a write-off creation appears --- .../reconciliation/reconciliation_renderer.js | 7 ++-- .../static/tests/reconciliation_tests.js | 38 +++++++++++++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/addons/account/static/src/js/reconciliation/reconciliation_renderer.js b/addons/account/static/src/js/reconciliation/reconciliation_renderer.js index 66c471dfbd3..33f969237d1 100644 --- a/addons/account/static/src/js/reconciliation/reconciliation_renderer.js +++ b/addons/account/static/src/js/reconciliation/reconciliation_renderer.js @@ -406,7 +406,8 @@ var LineRenderer = Widget.extend(FieldManagerMixin, { // mv_lines var $mv_lines = this.$('.match table tbody').empty(); - _.each(state.mv_lines.slice(0, state.limitMoveLines), function (line) { + var stateMvLines = state.mv_lines || []; + _.each(stateMvLines.slice(0, state.limitMoveLines), function (line) { var $line = $(qweb.render("reconciliation.line.mv_line", {'line': line, 'state': state})); if (!isNaN(line.id)) { $('') @@ -415,9 +416,9 @@ var LineRenderer = Widget.extend(FieldManagerMixin, { } $mv_lines.append($line); }); - this.$('.match .fa-chevron-right').toggleClass('disabled', state.mv_lines.length <= state.limitMoveLines); + this.$('.match .fa-chevron-right').toggleClass('disabled', stateMvLines.length <= state.limitMoveLines); this.$('.match .fa-chevron-left').toggleClass('disabled', !state.offset); - this.$('.match').css('max-height', !state.mv_lines.length && !state.filter.length ? '0px' : ''); + this.$('.match').css('max-height', !stateMvLines.length && !state.filter.length ? '0px' : ''); // balance this.$('.popover').remove(); diff --git a/addons/account/static/tests/reconciliation_tests.js b/addons/account/static/tests/reconciliation_tests.js index 111c5834b0a..513f642adfc 100644 --- a/addons/account/static/tests/reconciliation_tests.js +++ b/addons/account/static/tests/reconciliation_tests.js @@ -1760,5 +1760,43 @@ QUnit.module('account', { clientAction.destroy(); }); + + QUnit.test('Manual Reconciliation: No lines for account', function (assert) { + assert.expect(2); + + var clientAction = new ReconciliationClientAction.ManualAction(null, this.params.options); + testUtils.addMockEnvironment(clientAction, { + data: this.params.data, + session: { + currencies: { + 3: { + digits: [69, 2], + position: "before", + symbol: "$" + } + } + }, + }); + + clientAction.appendTo($('#qunit-fixture')); + + // The second reconciliation "line" is where it happens + var widget = clientAction.widgets[1]; + + var emptyLine = widget.$('tr.mv_line'); + + assert.notOk('data-line-id' in emptyLine.getAttributes(), + 'Empty line should be empty'); + + emptyLine.find('td:first').click(); + + // Check that a create form is here + var writeOffCreate = widget.$('div.create .create_account_id'); + + assert.equal(writeOffCreate.length, 1, + 'A write-off creation should be present'); + + clientAction.destroy(); + }); }); });