[FIX] account: bank transaction foreign currency compute

The foreign currency should not be computed if it has already been set.
In cases where the transactions were imported with a foreign currency amount, it should not be changed when the user modifies the date.

Fix for
Task-3338560

closes odoo/odoo#122780

X-original-commit: c31af99542493ca10604688dc2782a0aa41f5294
Signed-off-by: Laurent Smet <las@odoo.com>
This commit is contained in:
Habib (ayh)
2023-05-29 13:38:58 +02:00
parent 8d8478b49a
commit aa128cfd50
@@ -151,9 +151,10 @@ class AccountBankStatementLine(models.Model):
@api.depends('foreign_currency_id', 'date', 'amount', 'company_id')
def _compute_amount_currency(self):
for st_line in self:
if not st_line.foreign_currency_id or not st_line.date:
if not st_line.foreign_currency_id:
st_line.amount_currency = False
else:
elif st_line.date and not st_line.amount_currency:
# only convert if it hasn't been set already
st_line.amount_currency = st_line.currency_id._convert(
from_amount=st_line.amount,
to_currency=st_line.foreign_currency_id,