From da629810ad129fbde879de8190b6bdb3511ec20e Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Thu, 20 Jun 2019 17:20:19 +0530 Subject: [PATCH 1/3] fix: Get accounting dimensions only if user has access --- erpnext/public/js/utils.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js index f44fb0c1a67..86fa70d8ade 100755 --- a/erpnext/public/js/utils.js +++ b/erpnext/public/js/utils.js @@ -65,6 +65,9 @@ $.extend(erpnext, { }, get_dimension_filters: async function() { + if (!frappe.boot.user.can_read.includes('Accounting Dimension')) { + return + } let dimensions = await frappe.db.get_list('Accounting Dimension', { fields: ['label', 'fieldname', 'document_type'], filters: { From b663966c6821beafa2c77db24c245538f814aed7 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Thu, 20 Jun 2019 18:00:19 +0530 Subject: [PATCH 2/3] fix: Use can_read API --- erpnext/public/js/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js index 86fa70d8ade..dcc15fb5b3d 100755 --- a/erpnext/public/js/utils.js +++ b/erpnext/public/js/utils.js @@ -65,7 +65,7 @@ $.extend(erpnext, { }, get_dimension_filters: async function() { - if (!frappe.boot.user.can_read.includes('Accounting Dimension')) { + if (!frappe.model.can_read('Accounting Dimension')) { return } let dimensions = await frappe.db.get_list('Accounting Dimension', { From 01f56b867e13c837347fe26b3d2056a235e34d23 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Thu, 20 Jun 2019 18:07:58 +0530 Subject: [PATCH 3/3] fix: Return empty array to avoid failure --- erpnext/public/js/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js index dcc15fb5b3d..f4bb64a64d8 100755 --- a/erpnext/public/js/utils.js +++ b/erpnext/public/js/utils.js @@ -66,7 +66,7 @@ $.extend(erpnext, { get_dimension_filters: async function() { if (!frappe.model.can_read('Accounting Dimension')) { - return + return []; } let dimensions = await frappe.db.get_list('Accounting Dimension', { fields: ['label', 'fieldname', 'document_type'],