refactor(controllers): convert website_list_for_contact currency lookup to ORM

get_list_context built the enabled-currency symbol map with a raw
frappe.db.sql select. Convert to frappe.get_all (as_list). MariaDB-identical.

Adds a test asserting the currency-symbol map is built and contains a known
enabled currency, on both engines.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mihir Kandoi
2026-06-21 05:10:21 +05:30
parent 083858d450
commit c4d2228b36
2 changed files with 25 additions and 3 deletions

View File

@@ -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)

View File

@@ -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
)
)
),