Apply filter for child doctype in MultiSelectDialog

I have created a MultiSelectDialog to select items from the Reel Form Doctype. I want to filter the child table where the weight is not equal to 0. Here is the code snippet:

                    get_query() {
                        return {
                            filters: [
                                ['docstatus', '=', 1],
                                ['warehouse', '=',cur_frm.doc.source_warehouse],                            ]
                        };
                    },

This filter is only applied to the Reel Form Doctype, and I cannot apply it to the Child Doctype.

 new frappe.ui.form.MultiSelectDialog({
                    size : 'large',
                    doctype: "Reel Form",
                    target: frm,
                    setters: [,
                    {
                        fieldtype: 'Link',
                        label: __('Warehouse'),
                        options: 'Warehouse',
                        fieldname: 'warehouse',
                        default: cur_frm.doc.source_warehouse
                    }],
                    add_filters_group: 1,
                    data_field: "item_name",
                    allow_child_item_selection: 1,
                    child_fieldname: "items",
                    child_columns: ["item_name", "reel_name", "weight"],
                    get_query() {
                        return {
                            filters: [
                                ['docstatus', '=', 1],
                                ['warehouse', '=',cur_frm.doc.source_warehouse],                            ]
                        };
                    },

Hi @Dharanipathi,

Please like this and check it.

docstatus: ['=', 1],
warehouse: ['=', cur_frm.doc.source_warehouse],
weight: ['!=', 0]

Then reload and check it.

Thank You!

Thanks for the reply. The filter you mentioned applies to the Doctype. I want to apply it to its child table (Reel Items). How can I achieve this through code?@NCP

weight is a child table field, right?

if the child table field then already we shared the code for filtering out for the child table but it does not show in the filter level.

We applied for a purchase order from getting an item of Material request.

so it’s only above 3 qty related items to show.

Code:

    child_columns: ["item_code", "qty"], // child item columns to be displayed
    get_query() {
        return {
            filters: { docstatus: ['!=', 2],
                qty: ['>=', 3]
            }
        }
    },

Thank You!

Thank you for your reply. I believe I have identified the issue. Let’s assume that the Material Request has two items in its child table, with quantities of 60 and 56 respectively. When I apply a filter for a quantity of 60, the filter checks for the Parent Doctype which has a quantity of 60 in its child table. If it matches, I display all the items instead of just the one with a quantity of 60.@NCP