fix: Remove unnecessary checks for existing of 'is_virtual' field

This commit is contained in:
Andrew McLeod 2024-12-16 13:52:55 +00:00
parent 9469652fea
commit d3a525edb7

View file

@ -488,16 +488,13 @@ def get_link_fields(doctype: str) -> list[dict]:
.inner_join(dt)
.on(df.parent == dt.name)
.select(df.parent, df.fieldname, dt.issingle.as_("issingle"))
.where((df.options == doctype) & (df.fieldtype == "Link"))
.where(
(df.options == doctype) & (df.fieldtype == "Link")
& (dt.is_virtual == 0) & (df.is_virtual == 0)
)
)
if frappe.db.has_column("DocField", "is_virtual"):
standard_fields_query = standard_fields_query.where(df.is_virtual == 0)
virtual_doctypes = []
if frappe.db.has_column("DocType", "is_virtual"):
virtual_doctypes = frappe.get_all("DocType", {"is_virtual": 1}, pluck="name")
standard_fields_query = standard_fields_query.where(dt.is_virtual == 0)
virtual_doctypes = frappe.get_all("DocType", {"is_virtual": 1}, pluck="name")
standard_fields = standard_fields_query.run(as_dict=True)
@ -505,12 +502,10 @@ def get_link_fields(doctype: str) -> list[dict]:
custom_fields = (
frappe.qb.from_(cf)
.select(cf.dt.as_("parent"), cf.fieldname, cf_issingle)
.where((cf.options == doctype) & (cf.fieldtype == "Link"))
.where((cf.options == doctype) & (cf.fieldtype == "Link") & (cf.is_virtual == 0))
)
if virtual_doctypes:
custom_fields = custom_fields.where(cf.dt.notin(virtual_doctypes))
if frappe.db.has_column("Custom Field", "is_virtual"):
custom_fields = custom_fields.where(cf.is_virtual == 0)
custom_fields = custom_fields.run(as_dict=True)
ps_issingle = frappe.qb.from_(dt).select(dt.issingle).where(dt.name == ps.doc_type).as_("issingle")