mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-13 09:43:49 +00:00
fix(pegged currencies): skip adding currencies_to_add items on pegged_currency_item if source_currency or pegged_against currency doc does not exist (backport #51188) (#51203)
Co-authored-by: Diptanil Saha <diptanil@frappe.io> fix(pegged currencies): skip adding currencies_to_add items on pegged_currency_item if source_currency or pegged_against currency doc does not exist (#51188)
This commit is contained in:
@@ -296,8 +296,20 @@ def update_pegged_currencies():
|
||||
{"source_currency": "SAR", "pegged_against": "USD", "pegged_exchange_rate": 3.75},
|
||||
]
|
||||
|
||||
# Add items on pegged_currency_item if source_currency and pegged_against currency doc exist.
|
||||
|
||||
currencies_exist = frappe.db.get_list(
|
||||
"Currency", {"name": ["in", ["AED", "BHD", "JOD", "OMR", "QAR", "SAR", "USD"]]}, pluck="name"
|
||||
)
|
||||
|
||||
if "USD" not in currencies_exist:
|
||||
return
|
||||
|
||||
for currency in currencies_to_add:
|
||||
if currency["source_currency"] not in existing_sources:
|
||||
if (
|
||||
currency["source_currency"] in currencies_exist
|
||||
and currency["source_currency"] not in existing_sources
|
||||
):
|
||||
doc.append("pegged_currency_item", currency)
|
||||
|
||||
doc.save()
|
||||
|
||||
Reference in New Issue
Block a user