From bf33c4ea0c9412bf7b972ebe6ec42367fc7587a1 Mon Sep 17 00:00:00 2001 From: qdp-odoo Date: Fri, 22 Apr 2016 15:03:58 +0200 Subject: [PATCH] [FIX] account: bank statement reconciliation with taxes use case. The journal item for the bank should have the same amount as in the statement line except in case of already recorded payments only. Ticket 673358 --- addons/account/models/account_bank_statement.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py index aee7a4d4d4c..c77240b482d 100644 --- a/addons/account/models/account_bank_statement.py +++ b/addons/account/models/account_bank_statement.py @@ -848,14 +848,9 @@ class AccountBankStatementLine(models.Model): aml_dict['amount_currency'] = prorata_factor * self.amount aml_dict['currency_id'] = statement_currency.id - # Create the move line for the statement line using the total credit/debit of the counterpart - # This leaves out the amount already reconciled and avoids rounding errors from currency conversion - st_line_amount = sum(aml_dict['credit'] - aml_dict['debit'] for aml_dict in to_create) - aml_obj.with_context(check_move_validity=False).create(self._prepare_reconciliation_move_line(move, st_line_amount)) - # Create write-offs for aml_dict in new_aml_dicts: - aml_obj.with_context(check_move_validity=False).create(aml_dict, apply_taxes=False) + aml_obj.with_context(check_move_validity=False).create(aml_dict) # Create counterpart move lines and reconcile them for aml_dict in counterpart_aml_dicts: @@ -868,8 +863,14 @@ class AccountBankStatementLine(models.Model): aml_dict['currency_id'] = counterpart_move_line.currency_id.id aml_dict['amount_currency'] = company_currency.with_context(ctx).compute(aml_dict['debit'] - aml_dict['credit'], counterpart_move_line.currency_id) new_aml = aml_obj.with_context(check_move_validity=False).create(aml_dict) + (new_aml | counterpart_move_line).reconcile() + # Create the move line for the statement line using the bank statement line as the remaining amount + # This leaves out the amount already reconciled and avoids rounding errors from currency conversion + st_line_amount = -sum([x.balance for x in move.line_ids]) + aml_obj.with_context(check_move_validity=False).create(self._prepare_reconciliation_move_line(move, st_line_amount)) + move.post() counterpart_moves.assert_balanced() return counterpart_moves