feat: allow virtual child tables
This commit is contained in:
parent
2c92043998
commit
d6ab900f2a
2 changed files with 11 additions and 4 deletions
|
|
@ -538,7 +538,6 @@
|
|||
},
|
||||
{
|
||||
"default": "0",
|
||||
"depends_on": "eval:!doc.istable",
|
||||
"fieldname": "is_virtual",
|
||||
"fieldtype": "Check",
|
||||
"label": "Is Virtual"
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue