From d5e89d98c203809ee2bdbe9dd8025e072cc94114 Mon Sep 17 00:00:00 2001 From: Frappe PR Bot Date: Thu, 19 Aug 2021 17:09:21 +0530 Subject: [PATCH] fix: add child item groups into the filters (#26997) (#27034) * fix: add child item groups into the filters * fix: appending values to proper variable * fix: refactor the loop (cherry picked from commit c60d5523bca0a0631555a6234a485cd7a1e3c245) Co-authored-by: Afshan <33727827+AfshanKhan@users.noreply.github.com> --- .../item_group_wise_sales_target_variance.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/item_group_wise_sales_target_variance.py b/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/item_group_wise_sales_target_variance.py index d7ebafc2173..8778a3ca308 100644 --- a/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/item_group_wise_sales_target_variance.py +++ b/erpnext/selling/report/sales_partner_target_variance_based_on_item_group/item_group_wise_sales_target_variance.py @@ -44,6 +44,18 @@ def get_data(filters, period_list, partner_doctype): if d.item_group not in item_groups: item_groups.append(d.item_group) + if item_groups: + child_items = [] + for item_group in item_groups: + if frappe.db.get_value("Item Group", {"name":item_group}, "is_group"): + for child_item_group in frappe.get_all("Item Group", {"parent_item_group":item_group}): + if child_item_group['name'] not in child_items: + child_items.append(child_item_group['name']) + + for item in child_items: + if item not in item_groups: + item_groups.append(item) + date_field = ("transaction_date" if filters.get('doctype') == "Sales Order" else "posting_date")