From d3a525edb7da1111747cccb65f2bb27ab4d77e57 Mon Sep 17 00:00:00 2001 From: Andrew McLeod Date: Mon, 16 Dec 2024 13:52:55 +0000 Subject: [PATCH] fix: Remove unnecessary checks for existing of 'is_virtual' field --- frappe/model/rename_doc.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/frappe/model/rename_doc.py b/frappe/model/rename_doc.py index d1dcbafeab..2c85dc0cff 100644 --- a/frappe/model/rename_doc.py +++ b/frappe/model/rename_doc.py @@ -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")