From 2e7ad8980c28266e0afa89bde3d2c0a69b9af307 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 6 Mar 2014 12:28:47 +0530 Subject: [PATCH] fix for queries --- .../doctype/purchase_invoice/purchase_invoice.py | 2 +- erpnext/controllers/queries.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 5717dfb130..f0a9ecb838 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -442,4 +442,4 @@ def get_expense_account(doctype, txt, searchfield, start, page_len, filters): 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 9b68f12e42..1f8077fc8d 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 @@ def get_filters_cond(doctype, filters, conditions): 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