#NEWLINE# def rebuild_tree( doctype , parent_field ) : #NEWLINE# #INDENT# '\n\t\tcall rebuild_node for all root nodes\n\t' #NEWLINE# frappe . db . auto_commit_on_many_writes = 1 #NEWLINE# right = 1 #NEWLINE# result = frappe . db . sql ( ( "SELECT name FROM `tab%s` WHERE `%s`='' or `%s` IS NULL ORDER BY name ASC" % ( doctype , parent_field , parent_field ) ) ) #NEWLINE# for r in result : #NEWLINE# #INDENT# right = rebuild_node ( doctype , r [ 0 ] , right , parent_field ) #NEWLINE# #UNINDENT# frappe . db . auto_commit_on_many_writes = 0