From b0a7d62a9ea959fd5c76a90e968f65b0c16dc355 Mon Sep 17 00:00:00 2001 From: Akhil Narang Date: Mon, 27 May 2024 13:56:12 +0530 Subject: [PATCH] fix(address_query): use title field 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 4edf6dd8ee..87b468f085 100644 --- a/frappe/contacts/doctype/address/address.py +++ b/frappe/contacts/doctype/address/address.py @@ -288,9 +288,15 @@ def address_query(doctype, txt, searchfield, start, page_len, filters): else: search_condition += f" or `tabAddress`.`{field}` like %(txt)s" + # Use custom title field if set + if meta.show_title_field_in_link and meta.title_field: + title = f"`tabAddress`.{meta.title_field}" + else: + title = "`tabAddress`.city" + return frappe.db.sql( """select - `tabAddress`.name, `tabAddress`.city, `tabAddress`.country + `tabAddress`.name, {title}, `tabAddress`.country from `tabAddress` join `tabDynamic Link` @@ -312,6 +318,7 @@ def address_query(doctype, txt, searchfield, start, page_len, filters): mcond=get_match_cond(doctype), search_condition=search_condition, condition=condition or "", + title=title, ), { "txt": "%" + txt + "%",