fix: return early is parent doctype is single
This commit is contained in:
parent
2882ed4e69
commit
7ce888d5f1
1 changed files with 10 additions and 5 deletions
|
|
@ -1406,17 +1406,22 @@ class Engine:
|
|||
|
||||
For child tables (when parent_doctype is specified):
|
||||
- permissions are checked against the parent doctype
|
||||
- a join to the parent table is added
|
||||
- conditions reference the parent table's fields
|
||||
- for non-single parent doctypes: a join to the parent table is added,
|
||||
conditions reference parent fields
|
||||
- for single parent doctypes: all permissions are already checked by has_permission,
|
||||
we exit early without adding any conditions
|
||||
"""
|
||||
|
||||
if not self.apply_permissions:
|
||||
return
|
||||
|
||||
meta = frappe.get_meta(self.permission_doctype)
|
||||
if self.permission_doctype != self.doctype:
|
||||
parent_meta = frappe.get_meta(self.permission_doctype)
|
||||
if parent_meta.issingle:
|
||||
# Child table of single doctype
|
||||
# permissions are already checked by has_permission
|
||||
return
|
||||
|
||||
# For child tables, join to parent table so permission conditions can reference it (skip for Single doctypes)
|
||||
if self.permission_doctype != self.doctype and not meta.issingle:
|
||||
self.query = self.query.inner_join(self.permission_table).on(
|
||||
self.table.parent == self.permission_table.name
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue