From 763e4c93bc950bafd76bcb2159ccecdd4cefaba1 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 23 Aug 2012 18:33:58 +0530 Subject: [PATCH] added permission checking to show add child, edit and view ledger links in chart of accounts --- .../page/accounts_browser/accounts_browser.js | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/erpnext/accounts/page/accounts_browser/accounts_browser.js b/erpnext/accounts/page/accounts_browser/accounts_browser.js index 734e4de18a..4f35fd4156 100644 --- a/erpnext/accounts/page/accounts_browser/accounts_browser.js +++ b/erpnext/accounts/page/accounts_browser/accounts_browser.js @@ -116,15 +116,23 @@ erpnext.AccountsChart = Class.extend({ if(!data) return; link.toolbar = $('').insertAfter(link); + + var node_links = []; // edit - $('Edit').appendTo(link.toolbar); - - if(data.expandable) { - link.toolbar.append(' | Add Child'); - } else if(this.ctype=='Account') { - link.toolbar.append(' | View Ledger'); + if (wn.boot.profile.can_read.indexOf(this.ctype) !== -1) { + node_links.push('Edit'); } + if (data.expandable) { + if (wn.boot.profile.can_create.indexOf(this.ctype) !== -1 || + wn.boot.profile.in_create.indexOf(this.ctype) !== -1) { + node_links.push('Add Child'); + } + } else if (this.ctype === 'Account' && wn.boot.profile.can_read.indexOf("GL Entry") !== -1) { + node_links.push('View Ledger'); + } + + link.toolbar.append(node_links.join(" | ")); }, show_ledger: function() { var me = this;