Custom field is not fetching in material request when get item from bill of material

We make a custom field in item entry


Then I make BOM and all the item model is fetching in BOM

But when I want to make material request and “GET ITEM FROM BILL OF MATERIAL” then item model is not fetching

Please help me to solve this problem

@Arafat_Mehedi It’s not fetching because the table is built using js code getting data from python background . what you need to do is to open the material_request.js in the erpnext module . find the get_items_from_bom function , read the code and you will understand what needs to be done .

1 Like

@bahaou thanks for your reply. i understood your answer, but when i create material request and make purchase order with get_item_from_material_request then all item fetching correctly.

only BOM Item not fetching correctly when i want to get_item_from Bill of material.

@bahaou could you help me with get_items_from_bom function code example.

@Arafat_Mehedi first observe the method name and the fetching loop


open the function . it’s calling another function called (get_bom_items_as_dict)
add the field to the sql query . then add the field in the each loop at the js file .

@bahaou Dear, I am not good at programming. You have sent the default code, can you please tell me where and how to change the code.

@Arafat_Mehedi ok here add this :

 query = """select
			bom_item.item_code,
			bom_item.idx,
			item.item_name,
     --->   item.model

now open this and this :

     var d = frappe.model.add_child(cur_frm.doc, "Material Request Item", "items");  
     d.item_code = item.item_code;
---> d.model=item.model

just those 2 lines .
ps : if you making a custom app you need to override the files in your own app folder . but since you not a programmer you can leave it for anpther time , this will work for now

Yes I did it with your help.

thank you… thank you very much!

@Arafat_Mehedi set the reply as solution please so everyone can benefit from it