Fix record deletion problems

issue #21667: Unable to delete customer
issue #21633: Unable to delete sales order
issue #21666: Unable to delete prospect