From 1c6ba0cf825dcbcd60b9c6fd7f0aea3079ffa1f5 Mon Sep 17 00:00:00 2001 From: Akhil Narang Date: Thu, 30 May 2024 12:59:09 +0530 Subject: [PATCH] fix(address_query): show search fields in description if set Signed-off-by: Akhil Narang --- frappe/contacts/doctype/address/address.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frappe/contacts/doctype/address/address.py b/frappe/contacts/doctype/address/address.py index 87b468f085..90e4b51d94 100644 --- a/frappe/contacts/doctype/address/address.py +++ b/frappe/contacts/doctype/address/address.py @@ -294,9 +294,15 @@ def address_query(doctype, txt, searchfield, start, page_len, filters): else: title = "`tabAddress`.city" + # Get additional search fields + if searchfields: + extra_query_fields = ",".join([f"`tabAddress`.{field}" for field in searchfields]) + else: + extra_query_fields = "`tabAddress`.country" + return frappe.db.sql( """select - `tabAddress`.name, {title}, `tabAddress`.country + `tabAddress`.name, {title}, {extra_query_fields} from `tabAddress` join `tabDynamic Link` @@ -319,6 +325,7 @@ def address_query(doctype, txt, searchfield, start, page_len, filters): search_condition=search_condition, condition=condition or "", title=title, + extra_query_fields=extra_query_fields, ), { "txt": "%" + txt + "%",