[FIX] account: allow to reconcile batch payment

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) <qdp@openerp.com>
This commit is contained in:
Thibault Francois
2020-03-04 14:56:10 +00:00
parent 6282e45462
commit 92bd23746b
2 changed files with 5 additions and 4 deletions
@@ -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()
+3 -3
View File
@@ -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,