Skip to content

Commit

Permalink
fix: Don't fiddle with child table indexes (#26450) (#26452)
Browse files Browse the repository at this point in the history
- Link fields when referred to increase idx
- This is used in search.py to rank most referred documents higher than
- This doesn't make for child table links at all.

(cherry picked from commit 803f7b3)

Co-authored-by: Ankush Menat <ankush@frappe.io>
  • Loading branch information
mergify[bot] and ankush committed May 16, 2024
1 parent 267bfbc commit d0d6d93
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions frappe/model/base_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,13 +751,14 @@ def get_msg(df, docname):
# that are mapped as link_fieldname.source_fieldname in Options of
# Readonly or Data or Text type fields

meta = frappe.get_meta(doctype)
fields_to_fetch = [
_df
for _df in self.meta.get_fields_to_fetch(df.fieldname)
if not _df.get("fetch_if_empty")
or (_df.get("fetch_if_empty") and not self.get(_df.fieldname))
]
if not frappe.get_meta(doctype).get("is_virtual"):
if not meta.get("is_virtual"):
if not fields_to_fetch:
# cache a single value type
values = _dict(name=frappe.db.get_value(doctype, docname, "name", cache=True))
Expand All @@ -769,10 +770,10 @@ def get_msg(df, docname):
# don't cache if fetching other values too
values = frappe.db.get_value(doctype, docname, values_to_fetch, as_dict=True)

if getattr(frappe.get_meta(doctype), "issingle", 0):
if getattr(meta, "issingle", 0):
values.name = doctype

if frappe.get_meta(doctype).get("is_virtual"):
if meta.get("is_virtual"):
values = frappe.get_doc(doctype, docname).as_dict()

if values:
Expand All @@ -782,7 +783,8 @@ def get_msg(df, docname):
if self.is_new() or not self.docstatus.is_submitted() or _df.allow_on_submit:
self.set_fetch_from_value(doctype, _df, values)

notify_link_count(doctype, docname)
if not meta.istable:
notify_link_count(doctype, docname)

if not values.name:
invalid_links.append((df.fieldname, docname, get_msg(df, docname)))
Expand Down

0 comments on commit d0d6d93

Please sign in to comment.