fix for queries
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
index 5717dfb..f0a9ecb 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -442,4 +442,4 @@
 				and tabAccount.company = '%(company)s' 
 				and tabAccount.%(key)s LIKE '%(txt)s'
 				%(mcond)s""" % {'company': filters['company'], 'key': searchfield, 
-			'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype, searchfield)})
+			'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype)})
diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py
index 9b68f12..1f8077f 100644
--- a/erpnext/controllers/queries.py
+++ b/erpnext/controllers/queries.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 from frappe.widgets.reportview import get_match_cond
+from frappe.model.db_query import DatabaseQuery
 
 def get_filters_cond(doctype, filters, conditions):
 	if filters:
@@ -16,9 +17,12 @@
 				else:
 					flt.append([doctype, f[0], '=', f[1]])
 		
-		from frappe.widgets.reportview import build_filter_conditions
-		build_filter_conditions(flt, conditions)
-		cond = ' and ' + ' and '.join(conditions)	
+		query = DatabaseQuery(doctype)
+		query.filters = flt
+		query.conditions = conditions
+		query.build_filter_conditions()
+		
+		cond = ' and ' + ' and '.join(query.conditions)	
 	else:
 		cond = ''
 	return cond