fix: searchfields as per customize form not working for Item
This commit is contained in:
parent
d5359bbdc2
commit
fd889fd29a
@ -212,21 +212,15 @@ def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=Fals
|
|||||||
meta = frappe.get_meta(doctype, cached=True)
|
meta = frappe.get_meta(doctype, cached=True)
|
||||||
searchfields = meta.get_search_fields()
|
searchfields = meta.get_search_fields()
|
||||||
|
|
||||||
# these are handled separately
|
|
||||||
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 = [
|
extra_searchfields = [field for field in searchfields if not field in ["name", "description"]]
|
||||||
field
|
|
||||||
for field in searchfields
|
|
||||||
if not field in ["name", "item_group", "description", "item_name"]
|
|
||||||
]
|
|
||||||
|
|
||||||
if extra_searchfields:
|
if extra_searchfields:
|
||||||
columns = ", " + ", ".join(extra_searchfields)
|
columns += ", " + ", ".join(extra_searchfields)
|
||||||
|
|
||||||
|
if "description" in searchfields:
|
||||||
|
columns += """, if(length(tabItem.description) > 40, \
|
||||||
|
concat(substr(tabItem.description, 1, 40), "..."), description) as description"""
|
||||||
|
|
||||||
searchfields = searchfields + [
|
searchfields = searchfields + [
|
||||||
field
|
field
|
||||||
@ -266,12 +260,10 @@ def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=Fals
|
|||||||
if frappe.db.count(doctype, cache=True) < 50000:
|
if frappe.db.count(doctype, 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(
|
return frappe.db.sql(
|
||||||
"""select
|
"""select
|
||||||
tabItem.name, tabItem.item_name, tabItem.item_group,
|
tabItem.name {columns}
|
||||||
if(length(tabItem.description) > 40, \
|
|
||||||
concat(substr(tabItem.description, 1, 40), "..."), description) as description
|
|
||||||
{columns}
|
|
||||||
from tabItem
|
from tabItem
|
||||||
where tabItem.docstatus < 2
|
where tabItem.docstatus < 2
|
||||||
and tabItem.disabled=0
|
and tabItem.disabled=0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user