fix: print perm check logs from DB query

Doing has_permission and then manually raising exception erases the perm check messages.

This causes insane amounts of confusion when perm error says X not
permitted while user is trying to check Y.
This commit is contained in:
Ankush Menat 2024-01-11 12:27:39 +05:30
parent 141abf9faf
commit 9f135e8c1d

View file

@ -521,14 +521,12 @@ class DatabaseQuery:
def _set_permission_map(self, doctype: str, parent_doctype: str | None = None):
ptype = "select" if frappe.only_has_select_perm(doctype) else "read"
val = frappe.has_permission(
frappe.has_permission(
doctype,
ptype=ptype,
parent_doctype=parent_doctype or self.doctype,
throw=True,
)
if not val:
frappe.flags.error_message = _("Insufficient Permission for {0}").format(frappe.bold(doctype))
raise frappe.PermissionError(doctype)
self.permission_map[doctype] = ptype
def set_field_tables(self):