Skip to content
Snippets Groups Projects
Commit 01405ca1 authored by Julien (juc) Castiaux's avatar Julien (juc) Castiaux
Browse files

[FIX] account: currency of reconci. suggestion

When the currency used for a payment/internal transfert is not the same
as the company currency, the prices shown in the reconciliation
suggestions are computed using the company currency.

1) Enable multi-currency.
2) Setup two bank, one in USD, the other in EUR.
3) Leave the company currency to USD.
4) Create an invoice for a partner targeting the EUR bank and
   validate it.
5) Create a bank statement for the EUR bank amounting the **exact**
   value of the invoice for the **same** partner and reconcile it,
   this will create the payment behind the hood.
6) In the reconciliation the invoice appears as suggestion, if the
   currency symbol is correct, the amount is shown as USD.

opw-1937202

closes #30623

closes odoo/odoo#31290
parent 6530f125
Branches
Tags
No related merge requests found
......@@ -135,11 +135,12 @@ class AccountReconciliation(models.AbstractModel):
else:
aml_ids = matching_amls[line.id]['aml_ids']
bank_statements_left += line.statement_id
target_currency = line.currency_id or line.journal_id.currency_id or line.journal_id.company_id.currency_id
amls = aml_ids and self.env['account.move.line'].browse(aml_ids)
line_vals = {
'st_line': self._get_statement_line(line),
'reconciliation_proposition': aml_ids and self._prepare_move_lines(amls) or [],
'reconciliation_proposition': aml_ids and self._prepare_move_lines(amls, target_currency=target_currency, target_date=line.date) or [],
'model_id': matching_amls[line.id].get('model') and matching_amls[line.id]['model'].id,
'write_off': matching_amls[line.id].get('status') == 'write_off',
}
......
import logging
import odoo.tests
import time
from odoo.addons.account.tests.test_reconciliation import TestReconciliation
_logger = logging.getLogger(__name__)
......@@ -22,3 +23,29 @@ class TestUi(odoo.tests.HttpCase):
self.phantom_js("/web#statement_ids=" + str(bank_stmt.id) + "&action=bank_statement_reconciliation_view",
"odoo.__DEBUG__.services['web_tour.tour'].run('bank_statement_reconciliation')",
"odoo.__DEBUG__.services['web_tour.tour'].tours.bank_statement_reconciliation.ready", login="admin")
@odoo.tests.tagged('post_install', '-at_install')
class TestReconciliationWidget(TestReconciliation):
def test_statement_suggestion_other_currency(self):
# company currency is EUR
# payment in USD
invoice = self.create_invoice(invoice_amount=50, currency_id=self.currency_usd_id)
# journal currency in USD
bank_stmt = self.acc_bank_stmt_model.create({
'journal_id': self.bank_journal_usd.id,
'date': time.strftime('%Y-07-15'),
'name': 'payment %s' % invoice.number,
})
bank_stmt_line = self.acc_bank_stmt_line_model.create({'name': 'payment',
'statement_id': bank_stmt.id,
'partner_id': self.partner_agrolait_id,
'amount': 50,
'date': time.strftime('%Y-07-15'),
})
result = self.env['account.reconciliation.widget'].get_bank_statement_line_data(bank_stmt_line.ids)
self.assertEqual(result['lines'][0]['reconciliation_proposition'][0]['amount_str'], '$ 50.00')
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment