fix(stock): require ledger read access for ledger previews

(cherry picked from commit c42cb987fd)
This commit is contained in:
Mihir Kandoi
2026-10-28 06:58:27 +00:00
committed by Mergify
parent 5e2c49cc60
commit fd89a2fe16
2 changed files with 4 additions and 2 deletions
+2
View File
@@ -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)
+2 -2
View File
@@ -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 () {