Skip to content

Commit

Permalink
fix(address_query): use title field if set
Browse files Browse the repository at this point in the history
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
(cherry picked from commit b0a7d62)
  • Loading branch information
akhilnarang authored and mergify[bot] committed May 28, 2024
1 parent c839633 commit 01a00e3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion frappe/contacts/doctype/address/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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 + "%",
Expand Down

0 comments on commit 01a00e3

Please sign in to comment.