mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-16 11:39:18 +00:00
[minor] added webnotes.get_list, fixed webnotes/erpnext#663
This commit is contained in:
@@ -10,21 +10,8 @@ from accounts.utils import get_balance_on
|
||||
@webnotes.whitelist()
|
||||
def get_companies():
|
||||
"""get a list of companies based on permission"""
|
||||
|
||||
# check if match permission exists
|
||||
res = webnotes.conn.sql("""select role, `match` from `tabDocPerm`
|
||||
where parent='Account' and permlevel=0 and `read`=1""", as_dict=1)
|
||||
|
||||
roles = webnotes.user.get_roles()
|
||||
match = any((r["match"] for r in res
|
||||
if r["role"] in roles and r["match"]=="company"))
|
||||
|
||||
# if match == company is specified and companies are specified in user defaults
|
||||
if match:
|
||||
return webnotes.defaults.get_user_default_as_list("company")
|
||||
else:
|
||||
return [r[0] for r in webnotes.conn.sql("""select name from tabCompany
|
||||
where docstatus!=2""")]
|
||||
return [d.name for d in webnotes.get_list("Company", fields=["name"],
|
||||
order_by="name")]
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_children():
|
||||
|
||||
Reference in New Issue
Block a user