Item Code Dropdown Values [Custom Display] in Purchase order, Quote, Sales Invoice etc

Hi,

I’m looking for code or settings where we can customize the Dropdown list items.

Currently it’s showing Item_code, Item_group, item_Name

and i would like to change it to something like item_name and item_code.

i searched for this solution and found some Title link solutions dont know how they will work.

any help will be highly appreciated.

Hi,
It can be done only if you have your our Custom Application.
You need to overwrite core’s item_query.
I’ve resolved it in this way:
Added code below to the sales_order.js(or other doctype where you need)

cur_frm.cscript.custom_onload = function() {
	cur_frm.set_query("item_code", "items", function() {
		return {
			query: "path_to_your_new_script.item_query",
			filters: {'is_sales_item': 1}
		}
	});
}

and also I’ve created item_query(like core query) with the search fields which I need

Thanks NMyshuk,

Can you tell me where i can edit the core query? unfortunately i dont have Custom Application.

Thanks in Advance.

Hi, it isn’t a good idea to edit the core query:) here erpnext/erpnext/controllers/queries.py item_query

Thanks NMyshuk,

i tried editing the following query,

select tabItem.name, tabItem.item_group, tabItem.image,
if(length(tabItem.item_name) > 40,
concat(substr(tabItem.item_name, 1, 40), “…”), item_name) as item_name,
if(length(tabItem.description) > 40,
concat(substr(tabItem.description, 1, 40), “…”), description) as decription
from tabItem
but even if i remove the item_group it’s still appearing in display value.

But you should remove item_group it should be

select tabItem.name, tabItem.image,
if(length(tabItem.item_name) > 40,
concat(substr(tabItem.item_name, 1, 40), “…”), item_name) as item_name,
if(length(tabItem.description) > 40,
concat(substr(tabItem.description, 1, 40), “…”), description) as decription
from tabItem

yes this was my final query after removing item_group. but still in PO and other documents it was showing same values like before. no change

1)go to Customize Form
2)choose Item
3)change Search fields