fix: consider parent doctype when validating link to child row
This commit is contained in:
parent
443a81c8ab
commit
edd4171206
1 changed files with 10 additions and 7 deletions
|
|
@ -405,13 +405,16 @@ def validate_link(doctype: str, docname: str, fields=None):
|
|||
if not isinstance(docname, str):
|
||||
frappe.throw(_("Document Name must be a string"))
|
||||
|
||||
if doctype != "DocType" and not (
|
||||
frappe.has_permission(doctype, "select") or frappe.has_permission(doctype, "read")
|
||||
):
|
||||
frappe.throw(
|
||||
_("You do not have Read or Select Permissions for {}").format(frappe.bold(doctype)),
|
||||
frappe.PermissionError,
|
||||
)
|
||||
if doctype != "DocType":
|
||||
parent_doctype = frappe.db.get_value(doctype, docname, "parenttype") # needed for links to child rows
|
||||
if not (
|
||||
frappe.has_permission(doctype, "select", parent_doctype=parent_doctype)
|
||||
or frappe.has_permission(doctype, "read", parent_doctype=parent_doctype)
|
||||
):
|
||||
frappe.throw(
|
||||
_("You do not have Read or Select Permissions for {}").format(frappe.bold(doctype)),
|
||||
frappe.PermissionError,
|
||||
)
|
||||
|
||||
values = frappe._dict()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue