Search in item groups

Hello, i would like to know, how the filter works,
Because i have this situation, I have a master item group and subgroups, and when i put the filter to search for the subgroups its great, but when i put the master group i would like to see the itens insisde of the master group, and the ones witch are on the subgroups too! i hope you understand my situation

1 Like


You can write your custom query.
example, here I am filtering Item based on Item Group, if item group is not selected, I am showing all items.

 cur_frm.fields_dict['items'].grid.get_field("item_code").get_query = function(doc, cdt, cdn) {
        var item = frappe.get_doc(cdt, cdn);
        if(item.item_group_filter == "All Item Groups") {
            return {query: "erpnext.controllers.queries.item_query"} 
        else { 
                    return {query: "erpnext.controllers.queries.item_query", 
                    filters: (doc.order_type === "Maintenance" ?
                        {'is_service_item': 1, 'item_group': item.item_group_filter }:
                        {'is_sales_item': 1,'item_group': item.item_group_filter })

hi, thank you, but i am really confuse i dont know how the custom query works can you explain please