I need to update stock Quantity in Batch

Hi,

I want to know How can i get available quantity in batch and warehouse. While creating new batch from Split. As I’m using V12 for some reason.

It possible to update quantity and warehouse from client script to newly batch created. Because similar solution i need for other document.

Thank you

You can use get_batch_qty for getting current quantity of batch

Path: erpnext/stock/doctype/batch/batch.py

This method either work in on load or during refresh. This method Im using to show data.

But I need to have to save thing without refresh or onload.

Suppose I have batch BATCH001 have qty = 100kg. Now I’m in batch BATCH001 and click Split Batch then when new batch is created at that time it should set all the values in new batch as well as from which batch i created new batch.

Note: during split we don’t know new batch ID or doc.name.

Create Repack Stock Entry for your purpose, then you don’t need to update batch it will update itself everything

No we cannot use that because splitting is very frequent. Repack will take long time to create new batches.

Any Idea from server side?

By splitting you just updating the values in batch but what about stock, for stock movement you need to create stock entry, that is only option you have else your stock will remain in older Batch.

Refer split_batch function in batch.py

path : /home/frappe/frappe-bench/apps/erpnext/erpnext/stock/doctype/batch/batch.py