From aeb7e786a5e500c71d4e9fb5bf55c427189cadb3 Mon Sep 17 00:00:00 2001 From: Nandhinidevi123 Date: Tue, 26 Sep 2023 18:32:18 +0530 Subject: [PATCH] item group filter shon parent and its child group items --- .../item_wise_purchase_register.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py index ad196a903282..7b4d570d5018 100644 --- a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py +++ b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py @@ -293,10 +293,18 @@ def get_conditions(filters): ("from_date", " and `tabPurchase Invoice`.posting_date>=%(from_date)s"), ("to_date", " and `tabPurchase Invoice`.posting_date<=%(to_date)s"), ("mode_of_payment", " and ifnull(mode_of_payment, '') = %(mode_of_payment)s"), - ("item_group", " and ifnull(`tabPurchase Invoice Item`.item_group, '') = %(item_group)s"), ): if filters.get(opts[0]): conditions += opts[1] + if filters.get("item_group"): + parent_grps = [filters.get("item_group")] + child_groups = [] + for i in parent_grps: + child_groups.extend(frappe.get_all('Item Group', filters={'parent_item_group':['in', i]}, pluck='name')+frappe.get_all('Item Group', filters={'name':['in', i], "is_group":0}, pluck='name')) + parent_grps.extend(frappe.get_all('Item Group', filters={'parent_item_group':['in', i], 'is_group':1}, pluck='name')) + + child_groups+=parent_grps + conditions += f"""and ifnull(`tabPurchase Invoice Item`.item_group, '') in ("{'","'.join(child_groups)}")""" if not filters.get("group_by"): conditions += (