diff --git a/erpnext/stock/report/stock_balance/stock_balance.py b/erpnext/stock/report/stock_balance/stock_balance.py index 5d7c582609..0c71f9182e 100644 --- a/erpnext/stock/report/stock_balance/stock_balance.py +++ b/erpnext/stock/report/stock_balance/stock_balance.py @@ -225,16 +225,15 @@ def get_item_details(items, sle, filters): cf_join = "left join `tabUOM Conversion Detail` ucd on ucd.parent=item.name and ucd.uom='%s'" \ % frappe.db.escape(filters.get("include_uom")) - item_codes = ', '.join(['"' + frappe.db.escape(i, percent=False) + '"' for i in items]) res = frappe.db.sql(""" select - item.name, item.item_name, item.description, item.item_group, item.brand, item.stock_uom {cf_field} + item.name, item.item_name, item.description, item.item_group, item.brand, item.stock_uom %s from `tabItem` item - {cf_join} + %s where - item.name in ({item_codes}) and ifnull(item.disabled, 0) = 0 - """.format(cf_field=cf_field, cf_join=cf_join, item_codes=item_codes), as_dict=1) + item.name in (%s) and ifnull(item.disabled, 0) = 0 + """ % (cf_field, cf_join, ','.join(['%s'] *len(items))), items, as_dict=1) for item in res: item_details.setdefault(item.name, item) diff --git a/erpnext/stock/report/stock_ledger/stock_ledger.py b/erpnext/stock/report/stock_ledger/stock_ledger.py index 46c55d2ff3..20b5e45e19 100644 --- a/erpnext/stock/report/stock_ledger/stock_ledger.py +++ b/erpnext/stock/report/stock_ledger/stock_ledger.py @@ -113,7 +113,6 @@ def get_item_details(items, sl_entries, include_uom): cf_join = "left join `tabUOM Conversion Detail` ucd on ucd.parent=item.name and ucd.uom='%s'" \ % frappe.db.escape(include_uom) - item_codes = ', '.join([frappe.db.escape(i, percent=False) for i in items]) res = frappe.db.sql(""" select item.name, item.item_name, item.description, item.item_group, item.brand, item.stock_uom {cf_field} @@ -122,7 +121,7 @@ def get_item_details(items, sl_entries, include_uom): {cf_join} where item.name in ({item_codes}) - """.format(cf_field=cf_field, cf_join=cf_join, item_codes=item_codes), as_dict=1) + """.format(cf_field=cf_field, cf_join=cf_join, item_codes=','.join(['%s'] *len(items))), items, as_dict=1) for item in res: item_details.setdefault(item.name, item)