From aa128cfd5039d0c05d727cfaf31549068ed927d0 Mon Sep 17 00:00:00 2001 From: "Habib (ayh)" Date: Fri, 26 May 2023 16:02:12 +0000 Subject: [PATCH] [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 --- addons/account/models/account_bank_statement_line.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account_bank_statement_line.py b/addons/account/models/account_bank_statement_line.py index 7be0d32b879..f7a7a84b83c 100644 --- a/addons/account/models/account_bank_statement_line.py +++ b/addons/account/models/account_bank_statement_line.py @@ -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,