summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Perais (lpe) <lpe@odoo.com>2018-07-20 15:10:54 +0200
committerLucas Perais (lpe) <lpe@odoo.com>2018-07-31 09:18:31 +0200
commitebca7c3d372d3eac25db1491e9f7d49f92802f09 (patch)
tree3baff458347429c21acfb8482dc3175345916540
parent862c24557628a0ed9d80db20d6191454b6a55def (diff)
[FIX] account: reconciliation widget: remove prop to attain balance
In manual reconciliation (but probably automatic too) Have 3 lines for one account 2 of them are balanced the third is of an amount X Add the three lines to the reconciliation A write-off proposal of -X should appear Now, remove the third line by clicking on it Click on Reconcile Before this commit, the values sent to the server were wrong, as the write-off was still included After this commit, we make sure we don't send lines that are not displayed
-rw-r--r--addons/account/static/src/js/reconciliation/reconciliation_model.js4
-rw-r--r--addons/account/static/tests/reconciliation_tests.js73
2 files changed, 75 insertions, 2 deletions
diff --git a/addons/account/static/src/js/reconciliation/reconciliation_model.js b/addons/account/static/src/js/reconciliation/reconciliation_model.js
index dc3451ee110..0f37d6fc3ef 100644
--- a/addons/account/static/src/js/reconciliation/reconciliation_model.js
+++ b/addons/account/static/src/js/reconciliation/reconciliation_model.js
@@ -646,7 +646,7 @@ var StatementModel = BasicModel.extend({
return !isNaN(prop.id) && prop.already_paid;
}), 'id'),
"new_aml_dicts": _.map(_.filter(props, function (prop) {
- return isNaN(prop.id);
+ return isNaN(prop.id) && prop.display;
}), self._formatToProcessReconciliation.bind(self, line)),
};
@@ -1240,7 +1240,7 @@ var ManualModel = StatementModel.extend({
});
} else {
var mv_line_ids = _.pluck(_.filter(props, function (prop) {return !isNaN(prop.id);}), 'id');
- var new_mv_line_dicts = _.map(_.filter(props, function (prop) {return isNaN(prop.id);}), self._formatToProcessReconciliation.bind(self, line));
+ var new_mv_line_dicts = _.map(_.filter(props, function (prop) {return isNaN(prop.id) && prop.display;}), self._formatToProcessReconciliation.bind(self, line));
process_reconciliations.push({
id: null,
type: null,
diff --git a/addons/account/static/tests/reconciliation_tests.js b/addons/account/static/tests/reconciliation_tests.js
index e5ae62811fe..111c5834b0a 100644
--- a/addons/account/static/tests/reconciliation_tests.js
+++ b/addons/account/static/tests/reconciliation_tests.js
@@ -1687,5 +1687,78 @@ QUnit.module('account', {
clientAction.destroy();
});
+
+ QUnit.test('Manual Reconciliation: remove a prop to attain balance and reconcile', function (assert) {
+ assert.expect(5);
+
+ // tweak the data to fit our needs
+ this.params.data_for_manual_reconciliation_widget['[283, null, "", 0, 6]'] = _.extend({}, this.params.data_for_manual_reconciliation_widget['[null,null]']);
+ this.params.data_for_manual_reconciliation_widget['[283, null, "", 0, 6]'].accounts[0].reconciliation_proposition = [
+ {account_id: 283, account_type: "other", amount_currency_str: "", currency_id: false, date_maturity: "2017-03-18", date: "2017-02-16",
+ total_amount_str: "$ 500.00", partner_id: 8, account_name: "101000 Current Assets", name: "INV/2017/0987", partner_name: "Agrolait",
+ total_amount_currency_str: "", id: 999, credit: 0.0, journal_id: [1, "Customer Invoices"], amount_str: "$ 500.00", debit: 500.0,
+ account_code: "101000", ref: "", already_paid: false}
+ ];
+
+ var clientAction = new ReconciliationClientAction.ManualAction(null, this.params.options);
+ testUtils.addMockEnvironment(clientAction, {
+ data: this.params.data,
+ mockRPC: function (route, args) {
+ if (args.method === 'process_reconciliations') {
+ assert.deepEqual(args.args,
+ [
+ [{id: null, type: null,
+ mv_line_ids: [399, 402],
+ new_mv_line_dicts: []}
+ ]
+ ], "should call process_reconciliations without the new mv line dict");
+ }
+
+ return this._super(route, args);
+ },
+ session: {
+ currencies: {
+ 3: {
+ digits: [69, 2],
+ position: "before",
+ symbol: "$"
+ }
+ }
+ },
+ });
+
+ clientAction.appendTo($('#qunit-fixture'));
+
+ // The first reconciliation "line" is where it happens
+ var widget = clientAction.widgets[0];
+
+ // Add first prop
+ widget.$('.match .cell_account_code:first').trigger('click');
+ assert.notOk( widget.$('.cell_right .line_info_button').length,
+ "should not display the partial reconciliation alert");
+
+ // Add second prop
+ widget.$('.match .cell_account_code:first').trigger('click');
+
+ // Check that a create form is here
+ var writeOffCreate = widget.$('div.create');
+
+ assert.equal(writeOffCreate.length, 1,
+ 'A write-off creation should be present');
+
+ assert.equal(writeOffCreate.find('input[name=amount]').val(), 500,
+ 'The right amount should be proposed for the write-off');
+
+ // remove the first line, the other two will balance one another
+ widget.$('tr[data-line-id="999"] td:first').click()
+
+ var $buttonReconcile = widget.$('button.o_reconcile:not(hidden)');
+ assert.equal($buttonReconcile.length, 1,
+ 'The reconcile button must be visible');
+
+ $buttonReconcile.click();
+
+ clientAction.destroy();
+ });
});
});