ERPNext Conference 2019* ERPNext.com Blog

Search Fields for Item Doctype


#1

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


Customer Search Issue
#2

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


#3

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


#4

@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


#5

Everything can be fixed, questions is who? when?


#6

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


#7

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?


#8

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

Tks


#9

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

[1] https://github.com/frappe/erpnext/blob/develop/erpnext/selling/sales_common.js#L55


#10

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


#11

That is evaluated on the server side.


#12

Where ? so i can try to look into it


#13

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}
    }
  });
});

Change customer search filter based on other field
#14

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


#15

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!


#16

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


#17

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)

https://github.com/frappe/erpnext/issues
https://github.com/frappe/frappe/issues

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

cheers