Delete Linked Documents

Hi, I wish to delete documents even if they are linked to other doctypes. I know this is cause for a bad design structure but the way my custom app is structured. One parent doctype has many dependent doctypes. Let’s say I have a doctype called Invoice and I have a doctype called items. Now If i want to delete the items, I have to go back to the invoice, clear out the link fields and then delete the items. This whole process is proving to be tedious. Is there any way I can bypass this method of deleting only unlinked documents? Any help is appreciated.

I think you design calls for making the Item a table within the DocType without needing a link.

Another way is to make an on_trash (or after_delete) Controller def method on your python doctype class Item which will delete all reference to Item in the Invoice table.

what if i want to delete some docs in a live server and it has multiple links and i want to cancel those linked docs before deleting the docs