fix: use value from currency exchange when exchange api is disabled (backport #46137) (#46309)

fix: use value from currency exchange when exchange api is disabled (#46137)

(cherry picked from commit 2d26bff870)

Co-authored-by: Venkatesh <47534423+venkat102@users.noreply.github.com>
This commit is contained in:
mergify[bot]
2025-03-05 14:07:12 +05:30
committed by GitHub
parent 1ff085876e
commit ccc0358db6

View File

@@ -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}"