Work Order - Manufacture Stock Entry does not bring back split batches selected on Material Transfer

I create a Work Order.
I hit Start button, this brings me to the Stock Entry - Material Transfer for Manufacture.
I enter batch no for each items.
I need to split an Item line to pick from multiple batches for the same item.


I submit this Stock Entry, all is fine.
Then I hit Finish in the Work Order, this brings me to the Stock Entry - Manufacture.
The Items list did NOT bring back the split batch I made during the Material Transfer for Manufacture

Am I missing something here ? Why not bring back what I picked earlier ?

We faced the same issue before. We suggested to the client is to create another stock entry to create a batch with the required quantity. They should select only one batch in raw material transfer. Hope someone will be able to give better solution.

I did a quick & dirty fix in erpnext source code, if it can help.

1 Like

This is happening mainly because ERPNext fetched items from BOM does not consider the Qty transferred originally

We wrote a server side script in validations.py of custom app to fetch Items and Batches from corresponding Material Transfer to Manufacture and call this function in hooks.py

def stock_entry_validation(doc, method):
    if doc.stock_entry_type == "Manufacture":
        items = []
        last_item = doc.items[-1]
        doc.items = []
        name = frappe.get_value("Stock Entry", {"stock_entry_type":"Material Transfer for Manufacture", "work_order":doc.work_order, "docstatus":1}, "name")
        se_doc_mt = frappe.get_doc("Stock Entry", name)
        for se_item in se_doc_mt.items:
            doc.append("items",{"s_warehouse":doc.from_warehouse,
                          "item_code":se_item.item_code,
                          "item_group":se_item.item_group,
                          "qty":se_item.qty,
                          "uom":se_item.uom,
                          "conversion_factor":se_item.conversion_factor,
                          "stock_uom":se_item.stock_uom,
                          "transfer_qty":se_item.transfer_qty})
        doc.append("items", last_item)

3 Likes