Hi Morten,
You can prevent document deletion by setting Allow Document Deletion Before dates on Sales & Receivables Setup and Purchases & Payables Setup respectively.
For example lets say you need to keep last 5 years of financials records. Today being 2017, you'll need to keep records from 2012 till 2016, meaning you can delete records older from 2011.
So in this case in Allow Document Deletion Before date you'll set Jan 1st, 2012 and this will allow you to delete posted documents with posting dates before Jan 1st, 2012, but not the ones after it. You can set different dates for Sales and Purchase documents in their respective setups.

For demo purposes I've set the Allow Document Deletion Before date to Jan 1st, 2017. See the effect of it below.
