diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index c9a4ff090b4..e0c3f137eeb 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -410,7 +410,7 @@ def get_expense_account(doctype, txt, searchfield, start, page_len, filters): and tabAccount.docstatus!=2 and ifnull(tabAccount.master_type, "")="" and ifnull(tabAccount.master_name, "")="" - 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)}) + and tabAccount.company = %(company)s + and tabAccount.{key} LIKE %(txt)s + {mcond}""".format(key=searchfield, mcond=get_match_cond(doctype)), + {'company': filters['company'], 'txt': "%%{0}%%".format(txt)}) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 676a468aa95..8b23115e9a7 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -611,11 +611,10 @@ def get_income_account(doctype, txt, searchfield, start, page_len, filters): and tabAccount.docstatus!=2 and ifnull(tabAccount.master_type, "")="" and ifnull(tabAccount.master_name, "")="" - 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)}) - + and tabAccount.company = %(company)s + and tabAccount.{key} LIKE %(txt)s + {mcond}""".format(key=searchfield, mcond=get_match_cond(doctype)), + {'company': filters['company'], 'txt': "%%{0}%%".format(txt)}) @frappe.whitelist() def make_delivery_note(source_name, target_doc=None): diff --git a/erpnext/selling/report/customers_not_buying_since_long_time/customers_not_buying_since_long_time.py b/erpnext/selling/report/customers_not_buying_since_long_time/customers_not_buying_since_long_time.py index a87c4a119f8..458ae7bea4a 100644 --- a/erpnext/selling/report/customers_not_buying_since_long_time/customers_not_buying_since_long_time.py +++ b/erpnext/selling/report/customers_not_buying_since_long_time/customers_not_buying_since_long_time.py @@ -43,8 +43,8 @@ def get_so_details(): def get_last_so_amt(customer): res = frappe.db.sql("""select net_total from `tabSales Order` - where customer ='%(customer)s' and docstatus = 1 order by transaction_date desc - limit 1""" % {'customer':customer}) + where customer = %(customer)s and docstatus = 1 order by transaction_date desc + limit 1""", {'customer':customer}) return res and res[0][0] or 0