From cc498d3d54408efa9a318fc8d8ac01f9fa4886c5 Mon Sep 17 00:00:00 2001 From: Sagar Vora <16315650+sagarvora@users.noreply.github.com> Date: Fri, 16 Jan 2026 21:52:45 +0530 Subject: [PATCH 1/2] fix: dont mutate filters for custom queries --- frappe/desk/search.py | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/frappe/desk/search.py b/frappe/desk/search.py index d18ce76748..71483ff13c 100644 --- a/frappe/desk/search.py +++ b/frappe/desk/search.py @@ -109,28 +109,10 @@ def search_widget( if filters is None: filters = {} - are_filters_dict = isinstance(filters, dict) - include_disabled = False - if not query and are_filters_dict: - if "include_disabled" in filters: - if filters["include_disabled"] == 1: - include_disabled = True - filters.pop("include_disabled") - - filters = [make_filter_tuple(doctype, key, value) for key, value in filters.items()] - are_filters_dict = False - if for_link_validation: - if are_filters_dict: - # we add filter if possible, otherwise rely on txt - if "name" not in filters: - filters["name"] = txt - else: - filters.append([doctype, "name", "=", txt]) - as_dict = False - # for custom queries that don't respect filters but respect limit (rare) - # or for when we have to rely on txt + # for custom queries, we don't mutate filters + # we have to rely on txt # we want to match "A" with "A" only and not "A1", "BA" etc. page_length = PAGE_LENGTH_FOR_LINK_VALIDATION @@ -163,6 +145,19 @@ def search_widget( return [] meta = frappe.get_meta(doctype) + + include_disabled = False + if isinstance(filters, dict): + if "include_disabled" in filters: + if filters["include_disabled"] == 1: + include_disabled = True + filters.pop("include_disabled") + + filters = [make_filter_tuple(doctype, key, value) for key, value in filters.items()] + + if for_link_validation: + filters.append([doctype, "name", "=", txt]) + or_filters = [] # build from doctype From d4f1b51e98cf9eebcd1e0a9c6d57b569d74d8a0b Mon Sep 17 00:00:00 2001 From: Sagar Vora <16315650+sagarvora@users.noreply.github.com> Date: Fri, 16 Jan 2026 21:53:41 +0530 Subject: [PATCH 2/2] revert: "fix: ignore unsupported filter when querying dynamic link doctypes" This reverts commit bc590c084436eabb4aa19404dca554374a28664e. --- frappe/contacts/address_and_contact.py | 1 - 1 file changed, 1 deletion(-) diff --git a/frappe/contacts/address_and_contact.py b/frappe/contacts/address_and_contact.py index 16ae1ca68d..ae712f7c5a 100644 --- a/frappe/contacts/address_and_contact.py +++ b/frappe/contacts/address_and_contact.py @@ -116,7 +116,6 @@ def filter_dynamic_link_doctypes( txt = txt or "" filters = filters or {} - filters.pop("name", None) # ignore unsupported "name" filter - passed by validate_link_and_fetch _doctypes_from_df = frappe.get_all( "DocField",