Preheat the oven to 180'C.
Peel and finely dice the onion and garlic cloves. Pick the leaves from the thyme and discard the stalks.
If using dried beans, soak them overnight and then simmer for an hour in water until just tender.
If using tinned beans, drain and wash under cold water.
Heat a saucepan until over a medium heat and add the olive oil. Cook the onions until soft and translucent. Add the bacon cubes and cook until crispy and golden brown. Add the garlic, cook for a minute and then add the thyme, soy sauce and sugar. Stir in the beans and cover with the chopped tomatoes. Season with salt and pepper and then add enough hot vegetable stock so as the liquid is 1cm above the beans. Transfer the beans to an ovenproof dish and bake in the oven for 20-30 minutes or until most of the stock has been absorbed by the beans.
Remove the beans from the oven and just before serving stir in some torn basil leaves.
«This recipe can be adapted in many ways. Add some spice to the dish by adding chorizo instead of bacon. To make a complete dish, crack in some eggs to the beans once they are cooked and return to the oven for 5 minutes.»