Merge pull request #31386 from sokumon/orphan-child-table
fix: add check for child doctype if it has a valid parent
This commit is contained in:
commit
ce237efd58
1 changed files with 7 additions and 0 deletions
|
|
@ -504,6 +504,13 @@ def get_linked_docs(doctype: str, name: str, linkinfo: dict | None = None) -> di
|
|||
# dynamic link_context
|
||||
if doctype_fieldname := link_context.get("doctype_fieldname"):
|
||||
filters.append([linked_doctype, doctype_fieldname, "=", doctype])
|
||||
# check for child table that no one links to
|
||||
if linked_doctype_meta.istable:
|
||||
if not (
|
||||
frappe.db.exists("DocField", {"options": linked_doctype})
|
||||
or frappe.db.exists(linked_doctype, {"parenttype": doctype, "parent": name})
|
||||
):
|
||||
continue
|
||||
ret = frappe.get_list(
|
||||
doctype=linked_doctype, fields=fields, filters=filters, or_filters=or_filters, order_by=None
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue