How to make a function to delete record from custom module?

How to make a function to delete record from custom module?

I would like to create a function to delete a record from a custom module. I will usre a workflow to trgger the function that if the record meets a certain criteria i.e. the checkbox for "machine sold" is ticket the record is deleted.

I'm looking to go down this route as it doesn't' appear you can set a flag to use with the main delete record button on each record, so for now I have this ability turned off so they don't delete records without marking the machine has been sold. Creating a function that can run with a workflow would overcome this problem.

Please can somone show me example code for deleting the selected record?