summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Perais (lpe) <lpe@odoo.com>2018-07-20 15:46:16 +0200
committerLucas Perais (lpe) <lpe@odoo.com>2018-07-31 09:18:31 +0200
commitaa7bc410f01ffdbe2ff1d1dbb82f8daa194358e4 (patch)
treeb6fafee7d7c2f03cd9058793f775aa8153c4d212
parentebca7c3d372d3eac25db1491e9f7d49f92802f09 (diff)
[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
-rw-r--r--addons/account/static/src/js/reconciliation/reconciliation_renderer.js7
-rw-r--r--addons/account/static/tests/reconciliation_tests.js38
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)) {
$('<span class="line_info_button fa fa-info-circle"/>')
@@ -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();
+ });
});
});