fix(stock): Fixed stock balance and stock ledger report
diff --git a/erpnext/stock/report/stock_balance/stock_balance.py b/erpnext/stock/report/stock_balance/stock_balance.py
index 5d7c582..0c71f91 100644
--- a/erpnext/stock/report/stock_balance/stock_balance.py
+++ b/erpnext/stock/report/stock_balance/stock_balance.py
@@ -225,16 +225,15 @@
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 46c55d2..20b5e45 100644
--- a/erpnext/stock/report/stock_ledger/stock_ledger.py
+++ b/erpnext/stock/report/stock_ledger/stock_ledger.py
@@ -113,7 +113,6 @@
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 @@
{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)