Merge pull request #56870 from frappe/mergify/bp/version-16-hotfix/pr-56859

Fix(stock): item form permission errors (backport #56859)
This commit is contained in:
Mihir Kandoi
2026-07-04 14:18:51 +05:30
committed by GitHub
2 changed files with 14 additions and 1 deletions

View File

@@ -12,6 +12,9 @@ def get_data(
item_code=None, warehouse=None, item_group=None, start=0, sort_by="actual_qty", sort_order="desc"
):
"""Return data to render the item dashboard"""
if not frappe.has_permission("Bin", "read"):
return []
filters = []
if item_code:
filters.append(["item_code", "=", item_code])
@@ -33,7 +36,10 @@ def get_data(
if build_match_conditions("Warehouse", user=frappe.session.user):
filters.append(["warehouse", "in", [w.name for w in frappe.get_list("Warehouse")]])
except frappe.PermissionError:
# user does not have access on warehouse
# user does not have access on warehouse; build_match_conditions already queued a
# "Not permitted" message via frappe.throw before this was caught, drop it so the
# client doesn't show a spurious error for a request that's failing gracefully here
frappe.clear_last_message()
return []
items = frappe.db.get_all(

View File

@@ -668,6 +668,13 @@ $.extend(erpnext.item, {
render_item_prices: function (frm) {
if (frm.doc.__islocal) return;
if (!frappe.model.can_read("Item Price")) {
frm.toggle_display("prices_html", false);
return;
}
frm.toggle_display("prices_html", true);
const requested_item = frm.doc.name;
const container = frm.fields_dict["prices_html"].$wrapper;