Search Fields for Item Doctype

I changed search fields for Item doctype via Customize Form, but it didn’t take effect??

Please tell us what you are trying to achieve and what you did. Cant understand your query at the moment.

@jof2jc depends on the query, some queries don’t honour search_fields.

@neilLasrado I want to include supplier field in the item search fields so that I can search by supplier when adding item in SO, DN, SI. But the search fields not working.

Just try to change search fields under Customize Form - Item and it doesn’t take effect when searching the items.

Can this to be fixed?

Tks

Everything can be fixed, questions is who? when?

I would have fixed this if I can…but I’m not programmer expert. Can you help with some hints where to fix this? I would be happy to dig and learn to fix this…

Tks

This the item search query

It does honour search_fields, but depends on the calling form if it overrides this function. Which form are you not able to get them?

Try on Sales Invoice when adding and search for items…Where to see calling form’s function?

Tks

@jof2jc it seems to do item query [1], not sure what is not working. Do you want to debug the query?

[1] erpnext/sales_common.js at develop · frappe/erpnext · GitHub

@rmehta I don’t see it passed parameters in the sales_common.js?

That is evaluated on the server side.

Where ? so i can try to look into it

You can do this via custom client side script. In my case I needed to search items through custom field description_chinese

frappe.ui.form.on("Sales Order", "refresh", function (frm, cdt, cdn) {
  cur_frm.set_query("item_code", "items", function () {
    return { 
      query: "erpnext.controllers.queries.item_query",
      searchfield: "description_chinese",
      filters: {'is_sales_item': 1}
    }
  });
});
5 Likes

@gio never realized that searchfield needs to be passed. I guess it should be taken from the meta

I’m trying to search in PO based on manufacturer_part_no. So I tried your script but it doesn’t work.
Any suggestions?

frappe.ui.form.on("Purchase Order", "refresh", function (frm, cdt, cdn) {
  cur_frm.set_query("item_code", "items", function () {
    return { 
      query: "erpnext.controllers.queries.item_query",
      searchfield: "manufacturer_part_no",
      filters: {'is_purchase_item': 1}
    }
  });
});

Thanks!

I had to disable this script in erpnextv11 because there were an issue with custom scripts.

I was using that to search in item description while adding products to sales order or purchase order.

How can I enable this feature again?
Thanks

Yes odd posts of custom scripts not working - but a traceback is best to take action!?

A quick check for ‘custom’ turned up no smoking gun in either of these reports (just IMO)

Issues · frappe/erpnext · GitHub
Issues · frappe/frappe · GitHub

On Tuesdays this sums up fixes for the past week for eg [Release Notes] Version 11.1.7

cheers