mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-16 11:39:18 +00:00
(cherry picked from commit 34f5283c17)
Co-authored-by: Ankush Menat <ankush@frappe.io>
This commit is contained in:
@@ -211,12 +211,15 @@ def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=Fals
|
|||||||
meta = frappe.get_meta("Item", cached=True)
|
meta = frappe.get_meta("Item", cached=True)
|
||||||
searchfields = meta.get_search_fields()
|
searchfields = meta.get_search_fields()
|
||||||
|
|
||||||
if "description" in searchfields:
|
# these are handled separately
|
||||||
searchfields.remove("description")
|
ignored_search_fields = ("item_name", "description")
|
||||||
|
for ignored_field in ignored_search_fields:
|
||||||
|
if ignored_field in searchfields:
|
||||||
|
searchfields.remove(ignored_field)
|
||||||
|
|
||||||
columns = ''
|
columns = ''
|
||||||
extra_searchfields = [field for field in searchfields
|
extra_searchfields = [field for field in searchfields
|
||||||
if not field in ["name", "item_group", "description"]]
|
if not field in ["name", "item_group", "description", "item_name"]]
|
||||||
|
|
||||||
if extra_searchfields:
|
if extra_searchfields:
|
||||||
columns = ", " + ", ".join(extra_searchfields)
|
columns = ", " + ", ".join(extra_searchfields)
|
||||||
@@ -253,10 +256,8 @@ def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=Fals
|
|||||||
if frappe.db.count('Item', cache=True) < 50000:
|
if frappe.db.count('Item', cache=True) < 50000:
|
||||||
# scan description only if items are less than 50000
|
# scan description only if items are less than 50000
|
||||||
description_cond = 'or tabItem.description LIKE %(txt)s'
|
description_cond = 'or tabItem.description LIKE %(txt)s'
|
||||||
return frappe.db.sql("""select tabItem.name,
|
return frappe.db.sql("""select
|
||||||
if(length(tabItem.item_name) > 40,
|
tabItem.name, tabItem.item_name, tabItem.item_group,
|
||||||
concat(substr(tabItem.item_name, 1, 40), "..."), item_name) as item_name,
|
|
||||||
tabItem.item_group,
|
|
||||||
if(length(tabItem.description) > 40, \
|
if(length(tabItem.description) > 40, \
|
||||||
concat(substr(tabItem.description, 1, 40), "..."), description) as description
|
concat(substr(tabItem.description, 1, 40), "..."), description) as description
|
||||||
{columns}
|
{columns}
|
||||||
|
|||||||
Reference in New Issue
Block a user