From d056e1b453d2be424bc1d2032d7c1dbb8e1ec89c Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 5 Aug 2013 16:21:04 +0530 Subject: [PATCH] [minor] added webnotes.get_list, fixed webnotes/erpnext#663 --- .../page/accounts_browser/accounts_browser.py | 17 ++------------- setup/doctype/company/company.txt | 21 ++++++++++--------- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/accounts/page/accounts_browser/accounts_browser.py b/accounts/page/accounts_browser/accounts_browser.py index e3ca8894ae..61f4bfc521 100644 --- a/accounts/page/accounts_browser/accounts_browser.py +++ b/accounts/page/accounts_browser/accounts_browser.py @@ -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(): diff --git a/setup/doctype/company/company.txt b/setup/doctype/company/company.txt index 6ca3668075..768c7b1caf 100644 --- a/setup/doctype/company/company.txt +++ b/setup/doctype/company/company.txt @@ -2,7 +2,7 @@ { "creation": "2013-04-10 08:35:39", "docstatus": 0, - "modified": "2013-07-23 11:58:36", + "modified": "2013-08-05 15:39:36", "modified_by": "Administrator", "owner": "Administrator" }, @@ -157,15 +157,7 @@ "width": "50%" }, { - "depends_on": "eval:!doc.__islocal", - "doctype": "DocField", - "fieldname": "cost_center", - "fieldtype": "Link", - "label": "Cost Center", - "no_copy": 1, - "options": "Cost Center" - }, - { + "description": "To enable more currencies go to Setup > Currency", "doctype": "DocField", "fieldname": "default_currency", "fieldtype": "Link", @@ -174,6 +166,15 @@ "read_only": 0, "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", "doctype": "DocField",