浏览代码

[minor] return None is records are not available

version-14
mbauskar 8 年前
父节点
当前提交
389344489d
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. +3
    -2
      frappe/utils/nestedset.py

+ 3
- 2
frappe/utils/nestedset.py 查看文件

@@ -239,9 +239,10 @@ class NestedSet(Document):

def get_root_of(doctype):
"""Get root element of a DocType with a tree structure"""
return frappe.db.sql("""select t1.name from `tab{0}` t1 where
result = frappe.db.sql("""select t1.name from `tab{0}` t1 where
(select count(*) from `tab{1}` t2 where
t2.lft < t1.lft and t2.rgt > t1.rgt) = 0""".format(doctype, doctype))[0][0]
t2.lft < t1.lft and t2.rgt > t1.rgt) = 0""".format(doctype, doctype))
return result[0][0] if result else None

def get_ancestors_of(doctype, name):
"""Get ancestor elements of a DocType with a tree structure"""


正在加载...
取消
保存