Soak the beans overnight in plenty of cold water. Drain and rinse them and place in a large pan with the olive oil, onions, garlic and stock. Add the chopped ham, bring to the boil and simmer gently.
Peel the tomatoes by making a small cross in the skin and plunging them into boiling water for 20 seconds. Remove and peel the skins off. Chop the tomatoes roughly and add to the soup, along with the bay leaves and thyme, then simmer for 1½ hours. Season to taste, remove the bay leaves and thyme sprigs, add plenty of parsley, and serve.