diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index 2cdf076de2f..124b433fe33 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -1589,6 +1589,7 @@ def show_accounting_ledger_preview(company: str, doctype: str, docname: str): filters = frappe._dict(company=company, include_dimensions=1) doc = frappe.get_doc(doctype, docname) doc.check_permission("read") + frappe.has_permission("GL Entry", "read", throw=True) doc.run_method("before_gl_preview") gl_columns, gl_data = get_accounting_ledger_preview(doc, filters) @@ -1603,6 +1604,7 @@ def show_stock_ledger_preview(company: str, doctype: str, docname: str): filters = frappe._dict(company=company, valuation_field_type="Currency") doc = frappe.get_doc(doctype, docname) doc.check_permission("read") + frappe.has_permission("Stock Ledger Entry", "read", throw=True) doc.run_method("before_sl_preview") sl_columns, sl_data = get_stock_ledger_preview(doc, filters) diff --git a/erpnext/public/js/utils/ledger_preview.js b/erpnext/public/js/utils/ledger_preview.js index 9609a69d6d6..db59f1225df 100644 --- a/erpnext/public/js/utils/ledger_preview.js +++ b/erpnext/public/js/utils/ledger_preview.js @@ -3,7 +3,7 @@ frappe.provide("erpnext.accounts"); erpnext.accounts.ledger_preview = { show_accounting_ledger_preview(frm) { let me = this; - if (!frm.is_new() && frm.doc.docstatus == 0) { + if (!frm.is_new() && frm.doc.docstatus == 0 && frappe.model.can_read("GL Entry")) { frm.add_custom_button( __("Accounting Ledger"), function () { @@ -32,7 +32,7 @@ erpnext.accounts.ledger_preview = { show_stock_ledger_preview(frm) { let me = this; - if (!frm.is_new() && frm.doc.docstatus == 0) { + if (!frm.is_new() && frm.doc.docstatus == 0 && frappe.model.can_read("Stock Ledger Entry")) { frm.add_custom_button( __("Stock Ledger"), function () {