feat: Include child item group products in Item Group Page & cleanup

- Added 'Include descendants' checkbox, which will pull child item group products too
- Build item group filters in query engine file
- Include logic in filter engine
- Clean up Website section of Item Group page (UX)
- Add util to fetch child item groups including self

(cherry picked from commit b2755f6fdd)
This commit is contained in:
marination
2022-03-07 13:02:08 +05:30
committed by mergify-bot
parent b503b83960
commit 7f234c7e34
5 changed files with 69 additions and 41 deletions

View File

@@ -20,12 +20,14 @@
"sec_break_taxes",
"taxes",
"sb9",
"show_in_website",
"route",
"weightage",
"slideshow",
"website_title",
"description",
"show_in_website",
"include_descendants",
"column_break_16",
"weightage",
"slideshow",
"website_specifications",
"website_filters_section",
"filter_fields",
@@ -111,7 +113,7 @@
},
{
"default": "0",
"description": "Check this if you want to show in website",
"description": "Make Item Group visible in website",
"fieldname": "show_in_website",
"fieldtype": "Check",
"label": "Show in Website"
@@ -124,6 +126,7 @@
"unique": 1
},
{
"depends_on": "show_in_website",
"fieldname": "weightage",
"fieldtype": "Int",
"label": "Weightage"
@@ -186,6 +189,8 @@
"report_hide": 1
},
{
"collapsible": 1,
"depends_on": "show_in_website",
"fieldname": "website_filters_section",
"fieldtype": "Section Break",
"label": "Website Filters"
@@ -203,9 +208,21 @@
"options": "Website Attribute"
},
{
"depends_on": "show_in_website",
"fieldname": "website_title",
"fieldtype": "Data",
"label": "Title"
},
{
"fieldname": "column_break_16",
"fieldtype": "Column Break"
},
{
"default": "0",
"description": "Include Website Items belonging to child Item Groups",
"fieldname": "include_descendants",
"fieldtype": "Check",
"label": "Include Descendants"
}
],
"icon": "fa fa-sitemap",
@@ -214,11 +231,12 @@
"is_tree": 1,
"links": [],
"max_attachments": 3,
"modified": "2021-02-18 13:40:30.049650",
"modified": "2022-03-07 09:44:47.561532",
"modified_by": "Administrator",
"module": "Setup",
"name": "Item Group",
"name_case": "Title Case",
"naming_rule": "By fieldname",
"nsm_parent_field": "parent_item_group",
"owner": "Administrator",
"permissions": [
@@ -285,5 +303,6 @@
"search_fields": "parent_item_group",
"show_name_in_global_search": 1,
"sort_field": "modified",
"sort_order": "DESC"
"sort_order": "DESC",
"states": []
}

View File

@@ -112,7 +112,7 @@ class ItemGroup(NestedSet, WebsiteGenerator):
from erpnext.stock.doctype.item.item import validate_item_default_company_links
validate_item_default_company_links(self.item_group_defaults)
def get_child_groups_for_website(item_group_name, immediate=False):
def get_child_groups_for_website(item_group_name, immediate=False, include_self=False):
"""Returns child item groups *excluding* passed group."""
item_group = frappe.get_cached_value("Item Group", item_group_name, ["lft", "rgt"], as_dict=1)
filters = {
@@ -124,6 +124,12 @@ def get_child_groups_for_website(item_group_name, immediate=False):
if immediate:
filters["parent_item_group"] = item_group_name
if include_self:
filters.update({
"lft": [">=", item_group.lft],
"rgt": ["<=", item_group.rgt]
})
return frappe.get_all(
"Item Group",
filters=filters,