Unable to delete batch starting in V12

I am trying to delate a batch number on ERPNext version 12 but I got a message that says ’ Cannot delete because the batch is linked with the stock entry’ and then when I try to delate the stock entry I got a message ‘Cannot delete because stock entry is linked with batch.’
I was able to delate batch numbers on ERPNext version 11 but in this version 12, it seems like the steps to delete batches is different.
Can someone tell me what is the correct process to delate batches on ERPNext version 12, please?
Thanks in advance!


You cannot set/unset batch in case any transactions are associated with it… To know more about batch, check this link: Batch

Hi Michelle,

Thank for your reply.

I was able to delete a batch linked to the stock entry on version 11, but is in this new version 12 I cannot do it.
Is there another way that I can delete the batch, through the database maybe?

Thanks,

Esmeralda

1 Like

@gdlesvel, @Kaan_Oztoprak

yes that was possible in V11 but a code change in V12 caused not been able to delete a batch from an already ‘cancelled’ stock entry

frappe/model/delete_doc.py
Line 230:
elif (method != “Delete” or item.docstatus == 2) and (method != “Cancel” or item.docstatus != 1):
# don’t raise exception if not
# linked to a non-cancelled doc when deleting or to a submitted doc when cancelling
continue

@netchampfaris do you know if this change was on purposed?, the situation is the following, if for some reason the user generates a stock entry that at the same time generates a batch by mistake, the procedure that we were following was that the manager was canceling the stock entry, then deleting the batch, then finally deleting the stock entry (this with the objective of delete all transactions that were wrong)

but i cant delete batch after cancelling stock entry

The same is happening to me and it is very annoying.

ok both post # 1 and # 6 screenshots mark records that point to eachother.

Such ‘circular reference’ links may be valid and not an issue. And up to now users could easily delete the pair if need be.

But this PR seems to forbid that feat: Ignore certain linked documents on cancellation of document by deepeshgarg007 · Pull Request #8255 · frappe/frappe · GitHub

So now to delete such pairs, v12 users may have to manually delete them from the database.

How and whether that impacts the database integrity, users should test to inform themselves here!

please correct this becouse this is so annoying everytime delete manually from database. this should be done in gui. cannot delete batch no · Issue #20208 · frappe/erpnext · GitHub

Can anyone please guide on how to delete those entries manually ?