From f3f4ce9b87416cb7015628474ffc3360979da23c Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 1 Feb 2019 11:59:18 +0530 Subject: [PATCH] fix: Fetch data based on item group filter in item dashboard stock balance report --- erpnext/stock/dashboard/item_dashboard.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/dashboard/item_dashboard.py b/erpnext/stock/dashboard/item_dashboard.py index d817e5ff2d..6242fa767e 100644 --- a/erpnext/stock/dashboard/item_dashboard.py +++ b/erpnext/stock/dashboard/item_dashboard.py @@ -13,7 +13,13 @@ def get_data(item_code=None, warehouse=None, item_group=None, if warehouse: filters.append(['warehouse', '=', warehouse]) if item_group: - filters.append(['item_group', '=', item_group]) + lft, rgt = frappe.db.get_value("Item Group", item_group, ["lft", "rgt"]) + items = frappe.db.sql_list(""" + select i.name from `tabItem` i + where exists(select name from `tabItem Group` + where name=i.item_group and lft >=%s and rgt<=%s) + """, (lft, rgt)) + filters.append(['item_code', 'in', items]) try: # check if user has any restrictions based on user permissions on warehouse if DatabaseQuery('Warehouse', user=frappe.session.user).build_match_conditions():