refactor: migrate get_parent_customer_groups to query builder

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
(cherry picked from commit 91a2a7b0a0)
This commit is contained in:
diptanilsaha
2026-05-21 12:15:15 +05:30
committed by Mergify
parent dfc91441b4
commit 620161c526

View File

@@ -75,13 +75,11 @@ class CustomerGroup(NestedSet):
def get_parent_customer_groups(customer_group):
lft, rgt = frappe.db.get_value("Customer Group", customer_group, ["lft", "rgt"])
return frappe.db.sql(
"""select name from `tabCustomer Group`
where lft <= %s and rgt >= %s
order by lft asc""",
(lft, rgt),
as_dict=True,
return frappe.get_all(
"Customer Group",
filters=[["lft", "<=", lft], ["rgt", ">=", rgt]],
fields=["name"],
order_by="lft asc",
)