From 89c7b41fee04921e9df0b526694a846fd2e3c13a Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 6 Dec 2012 14:58:44 +0530 Subject: [PATCH] account_browser: remove can_create check --- .../doctype/sales_invoice/sales_invoice.py | 2 +- .../page/accounts_browser/accounts_browser.js | 6 +- website/utils.py | 68 +++++++++---------- website/web_cache.py | 7 +- 4 files changed, 42 insertions(+), 41 deletions(-) diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index 00a5bfae7b..b728475831 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -902,7 +902,7 @@ def assign_task_to_owner(inv, msg, users): def get_bank_cash_account(mode_of_payment): val = webnotes.conn.get_value("Mode of Payment", mode_of_payment, "default_account") if not val: - webnotes.msgprint("Default Account not set in Mode of Payment: %s" % mode_of_payment) + webnotes.msgprint("Default Bank / Cash Account not set in Mode of Payment: %s. Please add a Default Account in Mode of Payment master." % mode_of_payment) return { "cash_bank_account": val } \ No newline at end of file diff --git a/accounts/page/accounts_browser/accounts_browser.js b/accounts/page/accounts_browser/accounts_browser.js index a1e7764f4c..78776ce4a6 100644 --- a/accounts/page/accounts_browser/accounts_browser.js +++ b/accounts/page/accounts_browser/accounts_browser.js @@ -128,13 +128,11 @@ erpnext.AccountsChart = Class.extend({ var node_links = []; // edit - if (wn.boot.profile.can_read.indexOf(this.ctype) !== -1) { + if (wn.model.can_read(this.ctype) !== -1) { node_links.push('Edit'); } if (data.expandable) { - if(this.can_create) { - node_links.push('Add Child'); - } + node_links.push('Add Child'); } else if (this.ctype === 'Account' && wn.boot.profile.can_read.indexOf("GL Entry") !== -1) { node_links.push('View Ledger'); } diff --git a/website/utils.py b/website/utils.py index dae998d29f..58897a66b2 100644 --- a/website/utils.py +++ b/website/utils.py @@ -17,6 +17,40 @@ from __future__ import unicode_literals import webnotes +def render(page_name): + """render html page""" + import webnotes + try: + if page_name: + html = get_html(page_name) + else: + html = get_html('index') + except Exception, e: + html = get_html('404') + + from webnotes.handler import eprint, print_zip + eprint("Content-Type: text/html") + print_zip(html) + +def get_html(page_name): + """get page html""" + page_name = scrub_page_name(page_name) + comments = get_comments(page_name) + + import website.web_cache + html = website.web_cache.get_html(page_name, comments) + return html + +def get_comments(page_name): + import webnotes + + if page_name == '404': + comments = """error: %s""" % webnotes.getTraceback() + else: + comments = """page: %s""" % page_name + + return comments + def scrub_page_name(page_name): if page_name.endswith('.html'): page_name = page_name[:-5] @@ -41,37 +75,3 @@ def page_name(title): name = title.lower() name = re.sub('[~!@#$%^&*()<>,."\']', '', name) return '-'.join(name.split()[:4]) - -def render(page_name): - """render html page""" - import webnotes - try: - if page_name: - html = get_html(page_name) - else: - html = get_html('index') - except Exception, e: - html = get_html('404') - - from webnotes.handler import eprint, print_zip - eprint("Content-Type: text/html") - print_zip(html) - -def get_html(page_name): - """get page html""" - page_name = scrub_page_name(page_name) - comments = get_comments(page_name) - - import website.web_cache - html = website.web_cache.get_html(page_name, comments) - return html - -def get_comments(page_name): - import webnotes - - if page_name == '404': - comments = """error: %s""" % webnotes.getTraceback() - else: - comments = """page: %s""" % page_name - - return comments diff --git a/website/web_cache.py b/website/web_cache.py index 5e09e12057..2fb49fb2b9 100644 --- a/website/web_cache.py +++ b/website/web_cache.py @@ -31,6 +31,7 @@ def get_html(page_name, comments=''): # load from cache, if auto cache clear is falsy if not (hasattr(conf, 'auto_cache_clear') and conf.auto_cache_clear or 0): html = load_from_cache(page_name) + comments += "\n\npage load status: from cache" if not html: html = load_into_cache(page_name) @@ -82,7 +83,8 @@ def get_predefined_pages(): import conf import website.utils - pages_path = os.path.join(os.path.dirname(conf.__file__), 'app', 'website', 'templates', 'pages') + pages_path = os.path.join(os.path.dirname(conf.__file__), 'app', + 'website', 'templates', 'pages') page_list = [] @@ -121,7 +123,8 @@ def get_home_page(): def get_doc_fields(page_name): import webnotes - doc_type, doc_name = webnotes.conn.get_value('Web Cache', page_name, ['doc_type', 'doc_name']) + doc_type, doc_name = webnotes.conn.get_value('Web Cache', page_name, + ['doc_type', 'doc_name']) import webnotes.model.code obj = webnotes.model.code.get_obj(doc_type, doc_name)