Cannot delete or cancel because linked with GL Entry

I created a form Cheque Transaction. Which is get data from Purchase Invoice or Sales Invoice. Cheque Transaction amount will paid from journal entry. After Journal Entry submitted, I cannot cancel Cheque Transaction. I cancelled reference Journal Entry, but still showing message Cannot delete or cancel because linked with GL Entry.
cheque_transaction_message

How can I solve this issue?

Got to Accounts Settings and check if Deleting GL Entries is enabled:

https://docs.erpnext.com/docs/v13/user/manual/en/accounts/accounts-settings#7-delete-accounting-and-stock-ledger-entries-on-deletion-of-transaction

@kennethsequeira ,
Delete Accounting and Stock Ledger Entries on deletion of Transaction
this option already ticked. But still showing this message

How was the cheque transaction created? I couldn’t find a reference to it in the standard deployment

@kennethsequeira, Its a custom doctype

With custom doctype like this, you’ll need to unlink the reference to that journal entry using the controller hook before_submit(). I think you’ll need to set the GL Entry field in your check transaction to allow on submit, but readonly. That’ll allow you to unlink.

Also depends where you link actually, either you have a link to that cheque transaction in the GL Entry or you have a link to the GL Entry in the cheque transaction doctype.

1 Like

Cannot delete or cancel because Payroll Entry HR-PRUN-2022-00015 is linked
with GL Entry ACC-GLE-2022-38178

Had this problem when deleting Payroll Entries. Adding line 93 in the payroll_entry.py resolved it.