feat: add get_parent_supplier_groups using query builder

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

View File

@@ -70,3 +70,13 @@ class SupplierGroup(NestedSet):
def on_trash(self):
NestedSet.validate_if_child_exists(self)
frappe.utils.nestedset.update_nsm(self)
def get_parent_supplier_groups(supplier_group):
lft, rgt = frappe.db.get_value("Supplier Group", supplier_group, ["lft", "rgt"])
return frappe.get_all(
"Supplier Group",
filters=[["lft", "<=", lft], ["rgt", ">=", rgt]],
fields=["name"],
order_by="lft asc",
)