fix(stock): Fixed stock balance and stock ledger report

This commit is contained in:
Nabin Hait 2019-03-30 15:52:48 +05:30
parent f87a0e801a
commit da7a193f11
2 changed files with 5 additions and 7 deletions

View File

@ -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'" \ cf_join = "left join `tabUOM Conversion Detail` ucd on ucd.parent=item.name and ucd.uom='%s'" \
% frappe.db.escape(filters.get("include_uom")) % frappe.db.escape(filters.get("include_uom"))
item_codes = ', '.join(['"' + frappe.db.escape(i, percent=False) + '"' for i in items])
res = frappe.db.sql(""" res = frappe.db.sql("""
select 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 from
`tabItem` item `tabItem` item
{cf_join} %s
where where
item.name in ({item_codes}) and ifnull(item.disabled, 0) = 0 item.name in (%s) and ifnull(item.disabled, 0) = 0
""".format(cf_field=cf_field, cf_join=cf_join, item_codes=item_codes), as_dict=1) """ % (cf_field, cf_join, ','.join(['%s'] *len(items))), items, as_dict=1)
for item in res: for item in res:
item_details.setdefault(item.name, item) item_details.setdefault(item.name, item)

View File

@ -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'" \ cf_join = "left join `tabUOM Conversion Detail` ucd on ucd.parent=item.name and ucd.uom='%s'" \
% frappe.db.escape(include_uom) % frappe.db.escape(include_uom)
item_codes = ', '.join([frappe.db.escape(i, percent=False) for i in items])
res = frappe.db.sql(""" res = frappe.db.sql("""
select 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 {cf_field}
@ -122,7 +121,7 @@ def get_item_details(items, sl_entries, include_uom):
{cf_join} {cf_join}
where where
item.name in ({item_codes}) 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: for item in res:
item_details.setdefault(item.name, item) item_details.setdefault(item.name, item)