Try ERPNext Buy Support Partners Foundation Foundation Members

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: https://erpnext.com/docs/user/manual/en/stock/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

@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 https://github.com/frappe/frappe/pull/8255

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!