[fixes] setup control
This commit is contained in:
parent
1a8054994e
commit
869913c96b
@ -271,7 +271,7 @@ def create_territories():
|
|||||||
country = webnotes.conn.get_value("Control Panel", None, "country")
|
country = webnotes.conn.get_value("Control Panel", None, "country")
|
||||||
root_territory = get_root_of("Territory")
|
root_territory = get_root_of("Territory")
|
||||||
for name in (country, "Rest Of The World"):
|
for name in (country, "Rest Of The World"):
|
||||||
if not webnotes.conn.exists("Territory", name):
|
if name and not webnotes.conn.exists("Territory", name):
|
||||||
webnotes.bean({
|
webnotes.bean({
|
||||||
"doctype": "Territory",
|
"doctype": "Territory",
|
||||||
"territory_name": name,
|
"territory_name": name,
|
||||||
|
@ -32,14 +32,15 @@ def get_company_currency(company):
|
|||||||
def get_root_of(doctype):
|
def get_root_of(doctype):
|
||||||
"""Get root element of a DocType with a tree structure"""
|
"""Get root element of a DocType with a tree structure"""
|
||||||
result = webnotes.conn.sql_list("""select name from `tab%s`
|
result = webnotes.conn.sql_list("""select name from `tab%s`
|
||||||
where lft=1 and rgt=(select max(rgt) from `tab%s`)""" % (doctype, doctype))
|
where lft=1 and rgt=(select max(rgt) from `tab%s` where docstatus < 2)""" %
|
||||||
|
(doctype, doctype))
|
||||||
return result[0] if result else None
|
return result[0] if result else None
|
||||||
|
|
||||||
def get_ancestors_of(doctype, name):
|
def get_ancestors_of(doctype, name):
|
||||||
"""Get ancestor elements of a DocType with a tree structure"""
|
"""Get ancestor elements of a DocType with a tree structure"""
|
||||||
lft, rgt = webnotes.conn.get_value(doctype, name, ["lft", "rgt"])
|
lft, rgt = webnotes.conn.get_value(doctype, name, ["lft", "rgt"])
|
||||||
result = webnotes.conn.sql_list("""select name from `tab%s`
|
result = webnotes.conn.sql_list("""select name from `tab%s`
|
||||||
where lft<%s and rgt>%s""" % (doctype, "%s", "%s"), (lft, rgt))
|
where lft<%s and rgt>%s and docstatus < 2""" % (doctype, "%s", "%s"), (lft, rgt))
|
||||||
return result or None
|
return result or None
|
||||||
|
|
||||||
@webnotes.whitelist()
|
@webnotes.whitelist()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user