From 9735b0c8e9254840a2f1158b138624ad08895f99 Mon Sep 17 00:00:00 2001 From: singwangho Date: Fri, 3 Mar 2023 06:51:08 +0000 Subject: [PATCH 1/2] add basic support for statement line foreign currency --- .../models/reconciliation_widget.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/account_reconciliation_widget/models/reconciliation_widget.py b/account_reconciliation_widget/models/reconciliation_widget.py index cf78eb6f..3aaf5488 100644 --- a/account_reconciliation_widget/models/reconciliation_widget.py +++ b/account_reconciliation_widget/models/reconciliation_widget.py @@ -1020,11 +1020,14 @@ class AccountReconciliation(models.AbstractModel): statement_currency = ( st_line.journal_id.currency_id or st_line.journal_id.company_id.currency_id ) - if st_line.amount_currency and st_line.currency_id: - amount = st_line.amount_currency - amount_currency = st_line.amount + st_line_currency = ( + st_line.foreign_currency_id or st_line.currency_id or statement_currency + ) + if st_line.amount_currency and st_line.foreign_currency_id: + amount = st_line.amount + amount_currency = st_line.amount_currency amount_currency_str = formatLang( - self.env, abs(amount_currency), currency_obj=statement_currency + self.env, abs(amount_currency), currency_obj=st_line.foreign_currency_id ) else: amount = st_line.amount @@ -1045,7 +1048,7 @@ class AccountReconciliation(models.AbstractModel): "date": format_date(self.env, st_line.date), "amount": amount, "amount_str": amount_str, # Amount in the statement line currency - "currency_id": st_line.currency_id.id or statement_currency.id, + "currency_id": st_line_currency.id, # Currency according to statement line "partner_id": st_line.partner_id.id, "journal_id": st_line.journal_id.id, "statement_id": st_line.statement_id.id, From 7313df9b6a278cb1544cea6be602bf743b2e9920 Mon Sep 17 00:00:00 2001 From: singwangho Date: Thu, 16 Mar 2023 16:07:22 +0000 Subject: [PATCH 2/2] handle legacy case where st_line.currency_id is used as foreign currency --- account_reconciliation_widget/models/reconciliation_widget.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/account_reconciliation_widget/models/reconciliation_widget.py b/account_reconciliation_widget/models/reconciliation_widget.py index 3aaf5488..ac9defcc 100644 --- a/account_reconciliation_widget/models/reconciliation_widget.py +++ b/account_reconciliation_widget/models/reconciliation_widget.py @@ -1023,11 +1023,11 @@ class AccountReconciliation(models.AbstractModel): st_line_currency = ( st_line.foreign_currency_id or st_line.currency_id or statement_currency ) - if st_line.amount_currency and st_line.foreign_currency_id: + if st_line.amount_currency and (st_line_currency != statement_currency): amount = st_line.amount amount_currency = st_line.amount_currency amount_currency_str = formatLang( - self.env, abs(amount_currency), currency_obj=st_line.foreign_currency_id + self.env, abs(amount_currency), currency_obj=st_line_currency ) else: amount = st_line.amount