From 65e974096f4969303081c76d0067fabae1f84269 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Thu, 14 Nov 2013 14:50:43 +0530 Subject: [PATCH] [fix] showing customer dashboard headline to users with account related roles --- buying/doctype/supplier/supplier.js | 21 ++++++++++----------- selling/doctype/customer/customer.js | 17 ++++++++++------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/buying/doctype/supplier/supplier.js b/buying/doctype/supplier/supplier.js index 75542c8257..58045f5aa9 100644 --- a/buying/doctype/supplier/supplier.js +++ b/buying/doctype/supplier/supplier.js @@ -3,10 +3,6 @@ wn.require('app/setup/doctype/contact_control/contact_control.js'); -cur_frm.cscript.onload = function(doc,dt,dn){ - -} - cur_frm.cscript.refresh = function(doc,dt,dn) { cur_frm.cscript.make_dashboard(doc); if(sys_defaults.supp_master_name == 'Supplier Name') @@ -35,7 +31,8 @@ cur_frm.cscript.make_dashboard = function(doc) { cur_frm.dashboard.reset(); if(doc.__islocal) return; - cur_frm.dashboard.set_headline('Loading...') + if (in_list(user_roles, "Accounts User") || in_list(user_roles, "Accounts Manager")) + cur_frm.dashboard.set_headline('Loading...') cur_frm.dashboard.add_doctype_badge("Supplier Quotation", "supplier"); cur_frm.dashboard.add_doctype_badge("Purchase Order", "supplier"); @@ -49,12 +46,14 @@ cur_frm.cscript.make_dashboard = function(doc) { supplier: cur_frm.doc.name }, callback: function(r) { - cur_frm.dashboard.set_headline( - wn._("Total Billing This Year: ") + "" - + format_currency(r.message.total_billing, cur_frm.doc.default_currency) - + ' / ' + wn._("Unpaid") + ": " - + format_currency(r.message.total_unpaid, cur_frm.doc.default_currency) - + ''); + if (in_list(user_roles, "Accounts User") || in_list(user_roles, "Accounts Manager")) { + cur_frm.dashboard.set_headline( + wn._("Total Billing This Year: ") + "" + + format_currency(r.message.total_billing, cur_frm.doc.default_currency) + + ' / ' + wn._("Unpaid") + ": " + + format_currency(r.message.total_unpaid, cur_frm.doc.default_currency) + + ''); + } cur_frm.dashboard.set_badge_count(r.message); } }) diff --git a/selling/doctype/customer/customer.js b/selling/doctype/customer/customer.js index d2c632530b..014efe6dbd 100644 --- a/selling/doctype/customer/customer.js +++ b/selling/doctype/customer/customer.js @@ -45,7 +45,8 @@ cur_frm.cscript.setup_dashboard = function(doc) { cur_frm.dashboard.reset(doc); if(doc.__islocal) return; - cur_frm.dashboard.set_headline(''+ wn._('Loading...')+ '') + if (in_list(user_roles, "Accounts User") || in_list(user_roles, "Accounts Manager")) + cur_frm.dashboard.set_headline(''+ wn._('Loading...')+ '') cur_frm.dashboard.add_doctype_badge("Opportunity", "customer"); cur_frm.dashboard.add_doctype_badge("Quotation", "customer"); @@ -60,12 +61,14 @@ cur_frm.cscript.setup_dashboard = function(doc) { customer: cur_frm.doc.name }, callback: function(r) { - cur_frm.dashboard.set_headline( - wn._("Total Billing This Year: ") + "" - + format_currency(r.message.total_billing, cur_frm.doc.default_currency) - + ' / ' + wn._("Unpaid") + ": " - + format_currency(r.message.total_unpaid, cur_frm.doc.default_currency) - + ''); + if (in_list(user_roles, "Accounts User") || in_list(user_roles, "Accounts Manager")) { + cur_frm.dashboard.set_headline( + wn._("Total Billing This Year: ") + "" + + format_currency(r.message.total_billing, cur_frm.doc.default_currency) + + ' / ' + wn._("Unpaid") + ": " + + format_currency(r.message.total_unpaid, cur_frm.doc.default_currency) + + ''); + } cur_frm.dashboard.set_badge_count(r.message); } })