diff options
| author | Lucas Perais (lpe) <lpe@odoo.com> | 2018-07-23 16:44:52 +0200 |
|---|---|---|
| committer | Lucas Perais (lpe) <lpe@odoo.com> | 2018-07-31 09:18:31 +0200 |
| commit | 93e71d181ef85bbb5d22091f20c64de42265c957 (patch) | |
| tree | 57ea95e9bbc422dbddb62e1cec9b12005db40b41 | |
| parent | aa7bc410f01ffdbe2ff1d1dbb82f8daa194358e4 (diff) | |
[FIX] account: reconciliation widget: Don't loose pager on adding last line
Have a statement line with multiple pages of propositions
Go to the last page
Add everything
Before this commit, after clicking on the last item of the list,
a write-off creation was displayed, without any means to come back to the other
propositions
After this commit, we display the page before
| -rw-r--r-- | addons/account/static/src/js/reconciliation/reconciliation_model.js | 14 | ||||
| -rw-r--r-- | addons/account/static/tests/reconciliation_tests.js | 49 |
2 files changed, 63 insertions, 0 deletions
diff --git a/addons/account/static/src/js/reconciliation/reconciliation_model.js b/addons/account/static/src/js/reconciliation/reconciliation_model.js index 0f37d6fc3ef..f76304e6908 100644 --- a/addons/account/static/src/js/reconciliation/reconciliation_model.js +++ b/addons/account/static/src/js/reconciliation/reconciliation_model.js @@ -128,6 +128,20 @@ var StatementModel = BasicModel.extend({ var line = this.getLine(handle); var prop = _.clone(_.find(line.mv_lines, {'id': mv_line_id})); this._addProposition(line, prop); + + // Check whether we have some propositions left + // If we don't, it means we are on an empty page + // so let's go back to the previous page + // Through the offset + var propLineIds = _.map(line.reconciliation_proposition, function(prop) { + return prop.id; + }); + var leftOversProps = _.filter(line.mv_lines, function(mv_line) { + return propLineIds.indexOf(mv_line.id) === -1; + }); + if (line.offset && !leftOversProps.length) { + line.offset -= line.limitMoveLines; + } return $.when(this._computeLine(line), this._performMoveLine(handle)); }, /** diff --git a/addons/account/static/tests/reconciliation_tests.js b/addons/account/static/tests/reconciliation_tests.js index 513f642adfc..43be1879195 100644 --- a/addons/account/static/tests/reconciliation_tests.js +++ b/addons/account/static/tests/reconciliation_tests.js @@ -1798,5 +1798,54 @@ QUnit.module('account', { clientAction.destroy(); }); + + QUnit.test('Automatic Reconciliation: Don\'t loose pager when adding last line of a page', function (assert) { + assert.expect(2); + + function standard_partner (list, partner_id) { + _.each(list, function (item) { + item.partner_id = partner_id; + }); + }; + + this.params.options.params.limitMoveLines = 1; + standard_partner(this.params.mv_lines['[5,"",0,6]'], 8); + + // Overlap of those requests is normal + // the pager is implemented as: + // if there is at least 1 more line than my limit, the pager is active + this.params.mv_lines['[5,"",0,2]'] = this.params.mv_lines['[5,"",0,6]'].slice(0,2); + this.params.mv_lines['[5,"",1,2]'] = this.params.mv_lines['[5,"",0,6]'].slice(1,2); + + var clientAction = new ReconciliationClientAction.StatementAction(null, this.params.options); + testUtils.addMockEnvironment(clientAction, { + data: this.params.data, + session: { + currencies: { + 3: { + digits: [69, 2], + position: "before", + symbol: "$" + } + } + }, + }); + clientAction.appendTo($('#qunit-fixture')); + + var widget = clientAction.widgets[0]; + + var $nextPage = widget.$('.match .match_controls .fa-chevron-right:not(disabled)'); + assert.ok($nextPage.length, + 'We should have a next page'); + $nextPage.click(); + + // Add the second's page record + widget.$('.match tr[data-line-id=112] td:first').click(); + + assert.ok(widget.$('.match tr[data-line-id=109]').length, + 'the record of the first page must be proposed'); + + clientAction.destroy(); + }); }); }); |
