2
0
mirror of https://github.com/frappe/frappe.git synced 2024-06-12 19:12:23 +00:00

fix: Don't fiddle with child table indexes (#26450)

- 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.
This commit is contained in:
Ankush Menat 2024-05-16 17:09:56 +05:30 committed by GitHub
parent b2e3f3dcdd
commit 803f7b3990
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -803,13 +803,14 @@ class BaseDocument:
# 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))
@ -827,10 +828,10 @@ class BaseDocument:
or empty_values
)
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:
@ -840,7 +841,8 @@ class BaseDocument:
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)))