Merge pull request #16548 from nabinhait/stock-balance-item

fix: Fetch data based on item group filter in item dashboard stock balance report
This commit is contained in:
Nabin Hait 2019-02-05 10:36:47 +05:30 committed by GitHub
commit ad69e29334
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,7 +13,13 @@ def get_data(item_code=None, warehouse=None, item_group=None,
if warehouse: if warehouse:
filters.append(['warehouse', '=', warehouse]) filters.append(['warehouse', '=', warehouse])
if item_group: 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: try:
# check if user has any restrictions based on user permissions on warehouse # check if user has any restrictions based on user permissions on warehouse
if DatabaseQuery('Warehouse', user=frappe.session.user).build_match_conditions(): if DatabaseQuery('Warehouse', user=frappe.session.user).build_match_conditions():