fix(address_query): use title field if set

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
Akhil Narang 2024-05-27 13:56:12 +05:30
parent 43c8ae0049
commit b0a7d62a9e
No known key found for this signature in database
GPG key ID: 9DCC61E211BF645F

View file

@ -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 + "%",