How to show only specific "Item Group" while creating BOM

BOM is intended for manufacturing. While creating new BOM, In material section how can sort items, with some “Item Group” only.

For example: I have 25 Items i.e. 5 Products, 8 Raw Material, 7 Service, 2 Consumable, 3 Assembly item which used as per requirements.

But creating BOM, Already Finished Items also visible, somehow also services, which is generally different than operation. Also, I’m not looking for consumable here.

So, How Can I restrict some Item Groups or can only Show Specific Item Groups?

I had tried this, as mentioned here by Nabin here. By learning from here, I’m trying this at BOM Customization Form. Selected BOM Item and looked for Depends On field. Applied below condition there, to show only “Raw Material” item group.

eval:(doc.item_group=="Raw Material")

But, no luck there. Anyone will please help, what I’m doing wrong there?

Also tried this code as well.

eval:!in_list(["Services", "Products"], doc.item_group) or
eval:in_list(["Services", "Products"], doc.item_group)

I mean, I changed various types of syntax as well, nothing helped me. Also checked on “Ignore User Permissions”. Even tried building bench, clearing cache.

Will anyone help what’s actually correct syntax for “Depends On” condition.

Depends on field is specifically for showing/hiding the field.
What you need is get_query
See https://github.com/frappe/frappe/wiki/Client-Side-Scripting-Index#filter-the-selections-of-a-field-in-a-parent-document

Thankyou so much for reply.

I had tried.

I put this code in Custom Script, BOM Doctype. But, nothing worked. (I don’t now actually where I’m doing wrong.)

cur_frm.fields_dict['items'].get_query = function(doc, cdt, cdn) {
    	return{
    		filters:[
    			['items', 'item_group', 'Products, Services']
    		]
    	}
}

Also, tried this as well.

cur_frm.fields_dict['items'].get_query = function(doc, cdt, cdn) {
	return{
		filters:[
			['Items', 'Item Group', 'Products, Services']
		]
	}
}
  1. also, I had tried to made changes in /erpnext/manufacturing/doctype/bom/bom.js file like below. But, nothing worked.

var rm = doc.items || ['Item Group', 'Raw Material'];

Sometimes I noticed function(doc, cdt, cdn) as function(doc, dt, dn) what is difference among them. Where we can learn about these syntaxes? Actually, tried with or without function(doc, dt, dn) as well.

Anyone will help, filtering item, item group wise.

Any help here? What I’m doing wrong, why it’s not getting effective, can anyone indicate?

Try
['Item', 'item_group', 'in', ['Products', 'Services']]

1 Like

Hi @netchampfaris !!

This actually not working, same Consumables Items and Raw Materials are listing. I think, similar situation is happening here: Fetch a child table & what @snv is trying, same doing as well. Still, no solutions.

Use Case is: Like for a manufacturing company, while creating BOM, there is no need for finished items to be shown, I almost want to list there in BOM Items, “Raw Materials” Item Group only. Trying as well, but nothing works. Someone please help me here.

Hello Everyone,

not getting any answer to this query. No issues, I’m updating the question with some images what i want to achieve. Hope someone notice & help.

Actually, I mean with this query because What’s really need to include “Raw Materials” Item Group while creating BOM for production, obviously anyone will look to build either assembly items or Products. So, why we have to choose from thousands of list, with Item list contains all Item Groups. Can not we should filter it?

I’m talking about this:

and similarly, Why complete list for “Products” Item Group here at Materials required to build with help of BOM. Here, we should list contains “Raw Material”, “Services” and other Item Groups except finished Products. Here:

So, Just waiting to get resolved simple stuff for 13 days, I had tried, not solved somehow that’s why posted here, not to show I’m not coder. Help me please.

Hello All,

I had found a resolution one of my queries but another one is still not reflecting as expected.

While creating BOM, now I able to show only filtered Item Groups with below code.[WORKING]

cur_frm.fields_dict['item'].get_query = function(doc, cdt, cdn) {
	return{
		filters:[
			['Item', 'item_group', 'in', ['Products', 'Sub Assemblies']]
		]
	}
}

and while to filer Raw Items/Materials by which BOM will be finished is still note get solved, I actually restrict only a few “Item Groups” Finished Items, like Product, Services, Sub Assemblies which actually no need to make this list more complicated.

However, I tried below code. [NOT WORKING]

cur_frm.fields_dict['items'].get_query = function(doc, cdt, cdn) {
	return{
		filters:[
			['BOM Item', 'item_group', '!=', ['Products', 'Sub Assemblies']]
		]
	}
}

also tested, ‘Items’ instead of ‘BOM Item’, but don’t know why not resolved.

Oh Yeah, I can do same 1st code mentioned in this answer, to show many Item Groups but what will be after creating new Item Group. I have to manually add this everytime here in Custom Script, which is not feasible.

Any good solution?