Try ERPNext Buy Support Partners Foundation

Index Out of range when i try to filter

Hello i am getting this issue after doing a filter on table multiselect. can any1 help me?


this is the error i receive on the logs

  Request Error
Traceback (most recent call last):
  File "/home/erpnext/erpnext/frappe-bench/apps/frappe/frappe/app.py", line 64, in application
    response = frappe.api.handle()
  File "/home/erpnext/erpnext/frappe-bench/apps/frappe/frappe/api.py", line 59, in handle
    return frappe.handler.handle()
  File "/home/erpnext/erpnext/frappe-bench/apps/frappe/frappe/handler.py", line 24, in handle
    data = execute_cmd(cmd)
  File "/home/erpnext/erpnext/frappe-bench/apps/frappe/frappe/handler.py", line 64, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/erpnext/erpnext/frappe-bench/apps/frappe/frappe/__init__.py", line 1064, in call
    return fn(*args, **newargs)
  File "/home/erpnext/erpnext/frappe-bench/apps/frappe/frappe/desk/search.py", line 55, in search_link
    search_widget(doctype, txt, query, searchfield=searchfield, page_length=page_length, filters=filters, reference_doctype=reference_doctype, ignore_user_permissions=ignore_user_permissions)
  File "/home/erpnext/erpnext/frappe-bench/apps/frappe/frappe/desk/search.py", line 107, in search_widget
    filters.append([doctype, f[0], f[1][0], f[1][1]])
IndexError: list index out of range

What does your filter look like?
What happens if you remove it?

This is mu current filter

cur_frm.fields_dict['item_class'].get_query = function(doc) {
	return {
		filters: {
		        
	      "is_group": 0,
	      "parent_item_group" : doc.product_type

		}
	}

Although when i add more item in the product type it shows this error.

I think the filter syntax you are looking for is like this :

cur_frm.fields_dict['item_class'].get_query = function(doc) {
    return {
        filters: [
            ["Warehouse", "parent", "=", "Wicked Widgets - LSSA"],
            ["Warehouse", "name", "!=", "Radioactive Widgets - LSSA"],
        ]
    };

I hope I have correctly transcribed to older Javascript, I use ES6 so mine look like this:

cur_frm.fields_dict.from_stock.get_query = 
    () => ({ filters: [
      ["Warehouse", "parent", "=", "Envases Iridium Blue - LSSA"],
      ["Warehouse", "name", "!=", TS],
      ["Warehouse", "name", "!=", "Envases IB Rotos - LSSA"],
    ]
});

Of course, all that matters is the contents of the filters array.

hi i have adjusted the code it looks like some things like this

> cur_frm.fields_dict['item_class'].get_query = function(doc) {
>     return {
>         filters: [
>            
>             ["Item Group", "parent", "=",doc.product_type],
>             ["Item Group", "is_group", "=","0"],
>             
>         ]
>     };
> }

It is not filtering anything it doesn’t filter the parent of the item group based on the field product_type.