Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: split_batch does not handle externally supplied new_batch case #45347

Open
toofun666 opened this issue Jan 20, 2025 · 2 comments
Open

bug: split_batch does not handle externally supplied new_batch case #45347

toofun666 opened this issue Jan 20, 2025 · 2 comments

Comments

@toofun666
Copy link
Contributor

@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

@mihir-kandoi
Copy link
Contributor

Please describe the issue in detail with current behaviour and expected behaviour with screenshots or screen recordings if possible.

@toofun666
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants