diff --git a/erpnext/controllers/tests/test_website_list_for_contact.py b/erpnext/controllers/tests/test_website_list_for_contact.py new file mode 100644 index 00000000000..7d4a80aeec1 --- /dev/null +++ b/erpnext/controllers/tests/test_website_list_for_contact.py @@ -0,0 +1,19 @@ +# Copyright (c) 2025, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt + +import json + +from erpnext.tests.utils import ERPNextTestSuite + + +class TestWebsiteListForContact(ERPNextTestSuite): + def test_get_list_context_currency_symbols(self): + # get_list_context builds the enabled-currency symbol map via frappe.get_all (converted from + # raw SQL). Exercises that query and asserts a known enabled currency is present. + from erpnext.controllers.website_list_for_contact import get_list_context + + context = get_list_context() + + symbols = json.loads(context["currency_symbols"]) + self.assertIsInstance(symbols, dict) + self.assertIn("USD", symbols) diff --git a/erpnext/controllers/website_list_for_contact.py b/erpnext/controllers/website_list_for_contact.py index 7552b226285..07798305200 100644 --- a/erpnext/controllers/website_list_for_contact.py +++ b/erpnext/controllers/website_list_for_contact.py @@ -17,9 +17,12 @@ def get_list_context(context=None): "currency": frappe.db.get_default("currency"), "currency_symbols": json.dumps( dict( - frappe.db.sql( - """select name, symbol - from tabCurrency where enabled=1""" + frappe.get_all( + "Currency", + filters={"enabled": 1}, + fields=["name", "symbol"], + as_list=True, + limit_page_length=0, # all enabled currencies are needed for the symbol map ) ) ),