refactor: migrate get_parent_customer_groups to query builder

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
diptanilsaha
2026-05-21 12:15:15 +05:30
parent 341891e326
commit 91a2a7b0a0

View File

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