From 4b888b95d06cbf8dadf1dce4d838fc8cdb900976 Mon Sep 17 00:00:00 2001 From: KanchanChauhan Date: Tue, 25 Jul 2017 14:03:01 +0530 Subject: [PATCH] [Minor] Added filter condition to Customer Query (#10057) --- erpnext/controllers/queries.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py index 8130af925a..6d69a48ab8 100644 --- a/erpnext/controllers/queries.py +++ b/erpnext/controllers/queries.py @@ -60,6 +60,7 @@ def lead_query(doctype, txt, searchfield, start, page_len, filters): # searches for customer def customer_query(doctype, txt, searchfield, start, page_len, filters): + conditions = [] cust_master_name = frappe.defaults.get_user_default("cust_master_name") if cust_master_name == "Customer Name": @@ -79,7 +80,7 @@ def customer_query(doctype, txt, searchfield, start, page_len, filters): return frappe.db.sql("""select {fields} from `tabCustomer` where docstatus < 2 and ({scond}) and disabled=0 - {mcond} + {fcond} {mcond} order by if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999), if(locate(%(_txt)s, customer_name), locate(%(_txt)s, customer_name), 99999), @@ -88,7 +89,8 @@ def customer_query(doctype, txt, searchfield, start, page_len, filters): limit %(start)s, %(page_len)s""".format(**{ "fields": fields, "scond": searchfields, - "mcond": get_match_cond(doctype) + "mcond": get_match_cond(doctype), + "fcond": get_filters_cond(doctype, filters, conditions).replace('%', '%%'), }), { 'txt': "%%%s%%" % txt, '_txt': txt.replace("%", ""),