From 22c0d78ef41f460de473bfb2e72baaecaf55d7a7 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 4 Nov 2013 16:23:04 +0530 Subject: [PATCH] [minor] [fix] added end of life condition in item query --- controllers/queries.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/controllers/queries.py b/controllers/queries.py index 637d5e18cd..7681e6f350 100644 --- a/controllers/queries.py +++ b/controllers/queries.py @@ -117,21 +117,30 @@ def tax_account_query(doctype, txt, searchfield, start, page_len, filters): filters.get("company"), "%%%s%%" % txt, start, page_len])) def item_query(doctype, txt, searchfield, start, page_len, filters): + from webnotes.utils import nowdate + conditions = [] return webnotes.conn.sql("""select tabItem.name, if(length(tabItem.item_name) > 40, concat(substr(tabItem.item_name, 1, 40), "..."), item_name) as item_name, if(length(tabItem.description) > 40, \ - concat(substr(tabItem.description, 1, 40), "..."), description) as decription + concat(substr(tabItem.description, 1, 40), "..."), description) as decription from tabItem - where tabItem.docstatus<2 - and (tabItem.%(key)s LIKE "%(txt)s" - or tabItem.item_name LIKE "%(txt)s") - %(fcond)s %(mcond)s - limit %(start)s,%(page_len)s """ % {'key': searchfield, 'txt': "%%%s%%" % txt, - 'fcond': get_filters_cond(doctype, filters, conditions), - 'mcond': get_match_cond(doctype, searchfield), 'start': start, 'page_len': page_len}) + where tabItem.docstatus < 2 + and (ifnull(tabItem.end_of_life, '') = '' or tabItem.end_of_life > %(today)s) + and (tabItem.`{key}` LIKE %(txt)s + or tabItem.item_name LIKE %(txt)s) + {fcond} {mcond} + limit %(start)s, %(page_len)s """.format(key=searchfield, + fcond=get_filters_cond(doctype, filters, conditions), + mcond=get_match_cond(doctype, searchfield)), + { + "today": nowdate(), + "txt": "%%%s%%" % txt, + "start": start, + "page_len": page_len + }) def bom(doctype, txt, searchfield, start, page_len, filters): conditions = []