mirror of
https://github.com/frappe/erpnext.git
synced 2026-10-29 22:57:42 +00:00
fix(stock): require ledger read access for ledger previews
(cherry picked from commit c42cb987fd)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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 () {
|
||||
|
||||
Reference in New Issue
Block a user