fix: Handle custom child tables via check_parent_permission
Check `tabCustom Field` and `tabDocfield` for matching parent existence.
This commit is contained in:
parent
d1e229de2c
commit
33b7d7d74f
1 changed files with 5 additions and 2 deletions
|
|
@ -787,12 +787,15 @@ class DatabaseQuery(object):
|
|||
def check_parent_permission(parent, child_doctype):
|
||||
if parent:
|
||||
# User may pass fake parent and get the information from the child table
|
||||
if child_doctype and not frappe.db.exists('DocField',
|
||||
{'parent': parent, 'options': child_doctype}):
|
||||
if child_doctype and not (
|
||||
frappe.db.exists('DocField', {'parent': parent, 'options': child_doctype})
|
||||
or frappe.db.exists('Custom Field', {'dt': parent, 'options': child_doctype})
|
||||
):
|
||||
raise frappe.PermissionError
|
||||
|
||||
if frappe.permissions.has_permission(parent):
|
||||
return
|
||||
|
||||
# Either parent not passed or the user doesn't have permission on parent doctype of child table!
|
||||
raise frappe.PermissionError
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue