Heat a large frying pan and add 2 tablespoons of the olive oil, the onions, thyme and sugar. Fry for 10-15 minutes over a medium-low heat, or until softened and golden-brown, stirring occasionally.
Add the garlic and cook for 1 minute, then add the white wine and cook until the volume of liquid has reduced by half. Stir in the flour and cook for 2 minutes.
Add the brandy and sherry, then pour in the stock and bring to the boil. Reduce the heat slightly and cook for about 10-15 minutes.
Meanwhile, heat a griddle until hot. Drizzle the remaining olive oil over the bread and toast on one side. Set aside.
Season the soup to taste, adding a little more sugar or alcohol if needed.
Preheat the grill to high.
Ladle the soup into bowls and top with the bread, toasted side down. Add the cheese on top of the bread and grill until bubbling and golden-brown.