[minor] added webnotes.get_list, fixed webnotes/erpnext#663
This commit is contained in:
parent
0dae9f316a
commit
d056e1b453
@ -10,21 +10,8 @@ from accounts.utils import get_balance_on
|
|||||||
@webnotes.whitelist()
|
@webnotes.whitelist()
|
||||||
def get_companies():
|
def get_companies():
|
||||||
"""get a list of companies based on permission"""
|
"""get a list of companies based on permission"""
|
||||||
|
return [d.name for d in webnotes.get_list("Company", fields=["name"],
|
||||||
# check if match permission exists
|
order_by="name")]
|
||||||
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""")]
|
|
||||||
|
|
||||||
@webnotes.whitelist()
|
@webnotes.whitelist()
|
||||||
def get_children():
|
def get_children():
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-04-10 08:35:39",
|
"creation": "2013-04-10 08:35:39",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-07-23 11:58:36",
|
"modified": "2013-08-05 15:39:36",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@ -157,15 +157,7 @@
|
|||||||
"width": "50%"
|
"width": "50%"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"depends_on": "eval:!doc.__islocal",
|
"description": "To enable more currencies go to Setup > Currency",
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "cost_center",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Cost Center",
|
|
||||||
"no_copy": 1,
|
|
||||||
"options": "Cost Center"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "default_currency",
|
"fieldname": "default_currency",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
@ -174,6 +166,15 @@
|
|||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:!doc.__islocal",
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "cost_center",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Cost Center",
|
||||||
|
"no_copy": 1,
|
||||||
|
"options": "Cost Center"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"depends_on": "eval:!doc.__islocal",
|
"depends_on": "eval:!doc.__islocal",
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user