Skip to content

Commit

Permalink
Merge pull request #26422 from frappe/mergify/bp/version-14-hotfix/pr…
Browse files Browse the repository at this point in the history
…-26419

fix: make rename_doc work pre_model_sync (backport #26419)
  • Loading branch information
ankush committed May 13, 2024
2 parents 86368d0 + 0d631ce commit 53b5f29
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions frappe/model/rename_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,27 +440,29 @@ def get_link_fields(doctype: str) -> list[dict]:
frappe.flags.link_fields = {}

if doctype not in frappe.flags.link_fields:
virtual_doctypes = frappe.get_all("DocType", {"is_virtual": 1}, pluck="name")

dt = frappe.qb.DocType("DocType")
df = frappe.qb.DocType("DocField")
cf = frappe.qb.DocType("Custom Field")
ps = frappe.qb.DocType("Property Setter")

standard_fields = (
standard_fields_query = (
frappe.qb.from_(df)
.inner_join(dt)
.on(df.parent == dt.name)
.select(df.parent, df.fieldname, dt.issingle.as_("issingle"))
.where(
(df.options == doctype)
& (df.fieldtype == "Link")
& (df.is_virtual == 0)
& (dt.is_virtual == 0)
)
.run(as_dict=True)
.where((df.options == doctype) & (df.fieldtype == "Link"))
)

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)

standard_fields = standard_fields_query.run(as_dict=True)

cf_issingle = frappe.qb.from_(dt).select(dt.issingle).where(dt.name == cf.dt).as_("issingle")
custom_fields = (
frappe.qb.from_(cf)
Expand Down

0 comments on commit 53b5f29

Please sign in to comment.