Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
May 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading