Merge pull request #7249 from netchampfaris/get-all-ancestors

fix: Get all ancestors
This commit is contained in:
Rushabh Mehta 2019-04-11 09:26:04 +05:30 committed by GitHub
commit 3d7788ac2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -260,7 +260,7 @@ def get_ancestors_of(doctype, name, order_by="lft desc", limit=None):
"""Get ancestor elements of a DocType with a tree structure"""
lft, rgt = frappe.db.get_value(doctype, name, ["lft", "rgt"])
result = [d["name"] for d in frappe.db.get_list(doctype, {"lft": ["<", lft], "rgt": [">", rgt]},
result = [d["name"] for d in frappe.db.get_all(doctype, {"lft": ["<", lft], "rgt": [">", rgt]},
"name", order_by=order_by, limit_page_length=limit)]
return result or []