diff --git a/frappe/core/doctype/doctype/doctype.json b/frappe/core/doctype/doctype/doctype.json index d42fa62802..6cea37b539 100644 --- a/frappe/core/doctype/doctype/doctype.json +++ b/frappe/core/doctype/doctype/doctype.json @@ -538,7 +538,6 @@ }, { "default": "0", - "depends_on": "eval:!doc.istable", "fieldname": "is_virtual", "fieldtype": "Check", "label": "Is Virtual" diff --git a/frappe/core/doctype/doctype/doctype.py b/frappe/core/doctype/doctype/doctype.py index f7e6f28527..148e243ee3 100644 --- a/frappe/core/doctype/doctype/doctype.py +++ b/frappe/core/doctype/doctype/doctype.py @@ -923,7 +923,7 @@ class DocType(Document): self.nsm_parent_field = parent_field_name def validate_child_table(self): - if not self.get("istable") or self.is_new() or self.get("is_virtual"): + if not self.get("istable") or self.is_new(): # if the doctype is not a child table then return # if the doctype is a new doctype and also a child table then # don't move forward as it will be handled via schema @@ -1524,9 +1524,9 @@ def validate_fields(meta): return doctype = docfield.options - meta = frappe.get_meta(doctype) + child_doctype_meta = frappe.get_meta(doctype) - if not meta.istable: + if not child_doctype_meta.istable: frappe.throw( _("Option {0} for field {1} is not a child table").format( frappe.bold(doctype), frappe.bold(docfield.fieldname) @@ -1534,6 +1534,14 @@ def validate_fields(meta): title=_("Invalid Option"), ) + if not (meta.is_virtual == child_doctype_meta.is_virtual): + frappe.throw( + _( + "Option {0} for field {1} - Either both or none of the parent and child doctypes should be virtual" + ).format(frappe.bold(doctype), frappe.bold(docfield.fieldname)), + title=_("Invalid Option"), + ) + def check_max_height(docfield): if getattr(docfield, "max_height", None) and (docfield.max_height[-2:] not in ("px", "em")): frappe.throw(f"Max for {frappe.bold(docfield.fieldname)} height must be in px, em, rem")