Remove orphan links in DB

Hi,

How can I remove a link between documents from DB ?
I encountered a problem where a Purchase Receipt cannot be cancelled because it has a link with a Purchase Invoice.
But the actual Purchase Invoice is not there anymore already.
This could be because of previously meddling activities with the DB.

Any advise would be much appreciated

Never do this, most of the time you will end up with such mess. Direct operation on DB, does not execute controllers function and maintain integrity because no integrity check is there in the db level.

I think you have deleted records only from tabPurchase Invoice table, but not from tabPurchase Invoice Item table. Purchase Receipts are linked with PI via item table. To fix, delete item rows for the deleted PI based on parent column.

1 Like

Alright, won’t repeat that mistake again.