mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-17 08:28:44 +00:00
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:
19
erpnext/controllers/tests/test_website_list_for_contact.py
Normal file
19
erpnext/controllers/tests/test_website_list_for_contact.py
Normal 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)
|
||||
@@ -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
|
||||
)
|
||||
)
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user