From 3cde81be651313d4ec88560e500f5ef10a521402 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Sun, 17 Mar 2024 06:34:17 +0530 Subject: [PATCH] fix: don't validate for currency, if account is unavailable --- .../bank_transaction/bank_transaction.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/erpnext/accounts/doctype/bank_transaction/bank_transaction.py b/erpnext/accounts/doctype/bank_transaction/bank_transaction.py index 5e17881b6c12..4246ba5c032d 100644 --- a/erpnext/accounts/doctype/bank_transaction/bank_transaction.py +++ b/erpnext/accounts/doctype/bank_transaction/bank_transaction.py @@ -56,17 +56,17 @@ def validate_currency(self): Bank Transaction should be on the same currency as the Bank Account. """ if self.currency and self.bank_account: - account = frappe.get_cached_value("Bank Account", self.bank_account, "account") - account_currency = frappe.get_cached_value("Account", account, "account_currency") - - if self.currency != account_currency: - frappe.throw( - _( - "Transaction currency: {0} cannot be different from Bank Account({1}) currency: {2}" - ).format( - frappe.bold(self.currency), frappe.bold(self.bank_account), frappe.bold(account_currency) + if account := frappe.get_cached_value("Bank Account", self.bank_account, "account"): + account_currency = frappe.get_cached_value("Account", account, "account_currency") + + if self.currency != account_currency: + frappe.throw( + _( + "Transaction currency: {0} cannot be different from Bank Account({1}) currency: {2}" + ).format( + frappe.bold(self.currency), frappe.bold(self.bank_account), frappe.bold(account_currency) + ) ) - ) def set_status(self): if self.docstatus == 2: