[IMP] account_reconcile_oca: Fix multicurrency journal management

The main idea of this commit is to show the right currency amount
pull/691/head
Enric Tobella 2024-06-17 21:41:57 +02:00 committed by Luis Rodriguez
parent 2cdfaa9a44
commit 40b890d6e4
2 changed files with 56 additions and 8 deletions

View File

@ -53,18 +53,15 @@ class AccountReconcileAbstract(models.AbstractModel):
if amount < currency_max_amount < 0:
amount = currency_max_amount
net_amount = max_amount
amount = -amount
currency_amount = -amount
original_amount = -original_amount
net_amount = -net_amount
amount = amount_currency._convert(
currency_amount, self.company_id.currency_id, self.company_id, date
)
else:
amount_currency = line.currency_id
amount = self.company_id.currency_id._convert(
amount, amount_currency, self.company_id, date
)
currency_amount = amount
amount = amount_currency._convert(
amount, self.company_id.currency_id, self.company_id, date
)
currency_amount = line.amount_currency
vals = {
"reference": "account.move.line;%s" % line.id,
"id": line.id,

View File

@ -1020,3 +1020,54 @@ class TestReconciliationWidget(TestAccountReconciliationCommon):
self.assertTrue(bank_stmt_line.can_reconcile)
bank_stmt_line.reconcile_bank_line()
self.assertEqual(0, inv1.amount_residual)
def test_journal_foreign_currency_change(self):
self.env["res.currency.rate"].create(
{
"currency_id": self.env.ref("base.EUR").id,
"name": time.strftime("%Y-07-14"),
"rate": 1.15,
}
)
bank_stmt = self.acc_bank_stmt_model.create(
{
"company_id": self.env.ref("base.main_company").id,
"journal_id": self.bank_journal_usd.id,
"date": time.strftime("%Y-07-15"),
"name": "test",
}
)
bank_stmt_line = self.acc_bank_stmt_line_model.create(
{
"name": "testLine",
"journal_id": self.bank_journal_usd.id,
"statement_id": bank_stmt.id,
"amount": 100,
"date": time.strftime("%Y-07-15"),
}
)
with Form(
bank_stmt_line,
view="account_reconcile_oca.bank_statement_line_form_reconcile_view",
) as f:
line = f.reconcile_data_info["data"][0]
self.assertEqual(
line["currency_amount"],
100,
)
self.env["res.currency.rate"].create(
{
"currency_id": self.env.ref("base.EUR").id,
"name": time.strftime("%Y-07-15"),
"rate": 1.2,
}
)
with Form(
bank_stmt_line,
view="account_reconcile_oca.bank_statement_line_form_reconcile_view",
) as f:
line = f.reconcile_data_info["data"][0]
self.assertEqual(
line["currency_amount"],
100,
)