From 8bec4fa0157ad26ec786eee76651a28c8241828d Mon Sep 17 00:00:00 2001 From: qdp-odoo Date: Fri, 16 Mar 2018 17:23:02 +0100 Subject: [PATCH] [FIX] account: reconcilation simplest case The recent change (e1306066026649acd388b49d7429337d87cf819a) broke the use case of an invoice/payment in the company currency without any secondary currency involved. Payment was recorded correctly but no full reconciliation was created (and it was not tested). In order to fix that, we allow to test total_debit and total_credit also when currency has never been set (no secondary currency at all) --- addons/account/models/account_move.py | 7 ++++--- addons/account/tests/test_payment.py | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 8e6ad383f6d..df18aa8fca9 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -1822,7 +1822,7 @@ class AccountPartialReconcile(models.Model): total_amount_currency = 0 #make sure that all partial reconciliations share the same secondary currency otherwise it's not #possible to compute the exchange difference entry and it has to be done manually. - currency = self[0].debit_move_id.currency_id or self[0].credit_move_id.currency_id + currency = self[0].debit_move_id.currency_id or self[0].credit_move_id.currency_id or None more_than_1_currency = False maxdate = '0000-00-00' @@ -1838,7 +1838,7 @@ class AccountPartialReconcile(models.Model): more_than_1_currency = True if partial_rec.currency_id != currency: #no exchange rate entry will be created - currency = None + currency = False for aml in [partial_rec.debit_move_id, partial_rec.credit_move_id]: if aml not in aml_set: if aml.amount_residual or aml.amount_residual_currency: @@ -1863,7 +1863,8 @@ class AccountPartialReconcile(models.Model): aml_ids = aml_set.ids #if the total debit and credit are equal, or the total amount in currency is 0, the reconciliation is full digits_rounding_precision = aml_set[0].company_id.currency_id.rounding - if (currency and float_is_zero(total_amount_currency, precision_rounding=currency.rounding)) or (more_than_1_currency and float_compare(total_debit, total_credit, precision_rounding=digits_rounding_precision) == 0): + if (currency and float_is_zero(total_amount_currency, precision_rounding=currency.rounding)) or \ + ((currency is None or more_than_1_currency) and float_compare(total_debit, total_credit, precision_rounding=digits_rounding_precision) == 0): exchange_move_id = False if aml_to_balance: exchange_move = self.env['account.move'].create( diff --git a/addons/account/tests/test_payment.py b/addons/account/tests/test_payment.py index 73790c85309..bac638ccd85 100644 --- a/addons/account/tests/test_payment.py +++ b/addons/account/tests/test_payment.py @@ -139,6 +139,7 @@ class TestPayment(AccountingTestCase): {'account_id': self.account_eur.id, 'debit': 300.0, 'credit': 0.0, 'amount_currency': 0, 'currency_id': False}, {'account_id': inv_1.account_id.id, 'debit': 0.0, 'credit': 300.0, 'amount_currency': 00, 'currency_id': False}, ]) + self.assertTrue(payment.move_line_ids.filtered(lambda l: l.account_id == inv_1.account_id)[0].full_reconcile_id) liquidity_aml = payment.move_line_ids.filtered(lambda r: r.account_id == self.account_eur) bank_statement = self.reconcile(liquidity_aml, 200, 0, False)