Merge pull request #26570 from akhilnarang/fix-address-query-respect-custom-title

fix(address_query): use title field if set
This commit is contained in:
Akhil Narang 2024-05-28 15:34:44 +05:30 committed by GitHub
commit aa5febfe43
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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