From 92bd23746b2e3fe5a7b7e5dd0b5ed0061d58fcd8 Mon Sep 17 00:00:00 2001 From: Thibault Francois Date: Wed, 4 Mar 2020 10:45:12 +0000 Subject: [PATCH] [FIX] account: allow to reconcile batch payment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For the moment it's not possible to reconcile batch payment in multicurrency set up because the reconciliation trigger _compute_amount for all entry recompute_amout trigger _inverse_amount_total that will write on protected field such as debit, credit 1° when the currency is not same as company currency because the convertion was done from currency_id to currency_id and not currency_id to company_currency_id 2° even when the correction is correct you may have data that lead to different rate at the computation then when the move was originially computed 3° when you have float representation issue because != is use to compare float Solution: Fix _inverse_amount_total In Trigger the compute_amount only for invoice and since the method _inverse_amount_total try to change the amount only for entry with 2 lines the method will be never trigger during reconcilation. closes odoo/odoo#46886 X-original-commit: 5bd659fb16a44d1bc593cf932445e2cc628e12a8 Signed-off-by: Quentin De Paoli (qdp) --- addons/account/models/account_bank_statement.py | 3 ++- addons/account/models/account_move.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py index be9f711bf3e..baa2db9b709 100644 --- a/addons/account/models/account_bank_statement.py +++ b/addons/account/models/account_bank_statement.py @@ -951,7 +951,8 @@ class AccountBankStatementLine(models.Model): aml_dict['currency_id'] = statement_currency.id def _check_invoice_state(self, invoice): - invoice._compute_amount() + if invoice.is_invoice(include_receipts=True): + invoice._compute_amount() def button_confirm_bank(self): self.statement_id.button_confirm_bank() diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 53fe0cf8b7b..d3d7891d7d7 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -1155,20 +1155,20 @@ class AccountMove(models.Model): def _inverse_amount_total(self): for move in self: - if len(move.line_ids) != 2 or move.move_type != 'entry': + if len(move.line_ids) != 2 or move.is_invoice(include_receipts=True): continue to_write = [] if move.currency_id != move.company_id.currency_id: amount_currency = abs(move.amount_total) - balance = move.currency_id._convert(amount_currency, move.currency_id, move.company_id, move.date) + balance = move.currency_id._convert(amount_currency, move.company_currency_id, move.company_id, move.date) else: balance = abs(move.amount_total) amount_currency = 0.0 for line in move.line_ids: - if abs(line.balance) != balance: + if float_compare(abs(line.balance), balance, precision_rounding=move.currency_id.rounding) != 0: to_write.append((1, line.id, { 'debit': line.balance > 0.0 and balance or 0.0, 'credit': line.balance < 0.0 and balance or 0.0,