diff --git a/erpnext/setup/utils.py b/erpnext/setup/utils.py index 638c8af6263..e41f27b4d8c 100644 --- a/erpnext/setup/utils.py +++ b/erpnext/setup/utils.py @@ -68,9 +68,6 @@ def get_exchange_rate(from_currency, to_currency, transaction_date=None, args=No if not transaction_date: transaction_date = nowdate() - if rate := get_pegged_rate(from_currency, to_currency, transaction_date): - return rate - currency_settings = frappe.get_doc("Accounts Settings").as_dict() allow_stale_rates = currency_settings.get("allow_stale") @@ -100,6 +97,9 @@ def get_exchange_rate(from_currency, to_currency, transaction_date=None, args=No if frappe.get_cached_value("Currency Exchange Settings", "Currency Exchange Settings", "disabled"): return 0.00 + if rate := get_pegged_rate(from_currency, to_currency, transaction_date): + return rate + try: cache = frappe.cache() key = f"currency_exchange_rate_{transaction_date}:{from_currency}:{to_currency}"