You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@frappe.whitelist()
def split_batch(batch_no: str, item_code: str, warehouse: str, qty: float, new_batch_id: str | None = None):
"""Split the batch into a new batch"""
batch = frappe.get_doc(dict(doctype="Batch", item=item_code, batch_id=new_batch_id)).insert()
looks like the method may receive new_batch_id but it does not handle the case where it is fed beforehand. Please include necessary branching if the new batch to split into is provided by calling code
The text was updated successfully, but these errors were encountered:
I needed to override a class method for processing of the Purchase Receipt on_submit and split the batches created by the Purchase Receipt submission further as per the quantities entered in Purchase Receipt Items for each item that has batch control.
During this, I needed to print labels, so I needed the new batch numbers created at this split process.
Since it was a deferred commit operation, checking immediately the batches created at the database is not possible. (maybe that is why the split_batch method is returning batch.name batch being the new batch created for Outward stock entry.
I noticed the split_batch accepts a predetermined target batch, so I was planning to supply it but obviously it returned a batch already exists message breaking the process.
I guess the .insert() at the end of the line breaks this. Or you should control if the new_batch_id is existing or not.
@frappe.whitelist()
def split_batch(batch_no: str, item_code: str, warehouse: str, qty: float, new_batch_id: str | None = None):
"""Split the batch into a new batch"""
batch = frappe.get_doc(dict(doctype="Batch", item=item_code, batch_id=new_batch_id)).insert()
looks like the method may receive new_batch_id but it does not handle the case where it is fed beforehand. Please include necessary branching if the new batch to split into is provided by calling code
The text was updated successfully, but these errors were encountered: