Multi-level BOM creation

Hi,

Is there a way to quickly create a project-specific multi-level BOM? I am able to create the child items BOMs. Once this is done, they are assigned an ID. Now when I create the parent BOM which will be linked to these child BOMs, I have to look up the ID for each of the child BOMs. This takes a while (we don’t have a ‘default’ BOM since each is project-specific). The quickest way I’ve found to do this is via the data import tool but that isn’t ideal. Any suggestions?

Thanks

Perhaps you can consider customizing BOM naming (based on Project?), so that selection of child BOMs will be easier and faster.

Thanks for your reply @umair.
I have changed the autoname function to define the BOM name as:

self.project + ' ' + self.item

Is there a way to automatically fetch the BOM no in the BOM items table, either on entering the BOM project and BOM item item_code fields or on saving the BOM?

Thanks again

Hi @ishanloya ! As what @umair mentioned, this is very possible through customization. You should add scripts for this to happen. To know more about scripting, you can see here or search around the forum with the same usecase.

Regards

Thanks @creamdory. Would js/py be better for this?

Hi @ishanloya! You can have it in JS as you mentioned you want to trigger it upon selection of BOM Project or BOM Item item_code. You may refer usecases like this: link

Regards

Ok. The issue is that one of the fields (item_code) is in BOM item (child table) and the other (project) is in the parent doc (BOM). This is what is complicating the matter. Will do some more research on the forums.

Thanks again

1 Like

This is what I’ve got. Not sure if this is the best approach to do this:

def set_bom_numbers(self):
		for item in self.get("items"):
			bom_nos = frappe.db.sql("""select distinct bom.name from `tabBOM` bom,`tabBOM Item` bom_item
			where bom.project = %s
				and bom.item = %s
				and bom.is_active=1""", (self.project, item.item_code))
			if bom_nos:
				item.bom_no = cstr(bom_nos[0][0])

Hi!
May you give me this script?
Thanks

i about:

I have changed the autoname function to define the BOM name as:

self.project + ’ ’ + self.item