Begin by peeling and slicing the onions into thin, even slices.
In a large pot or Dutch oven, heat the olive oil and butter over medium heat.
Add the sliced onions, sugar, and a pinch of salt. Cook the onions, stirring frequently until they become soft and caramelized, about 30 minutes. Reduce the heat if the onions start to burn.
Once caramelized, add black pepper and thyme to the onions and continue to cook for another minute.
Pour in the white wine (if using) and scrape any browned bits from the bottom of the pot. Allow it to reduce for about 5 minutes.
Add the beef stock and bring the soup to a simmer. Let it cook for an additional 15 minutes to blend the flavors. Taste and adjust seasoning if necessary.
While the soup simmers, preheat your oven to 350°F (175°C).
Place the slices of French bread on a baking sheet and toast them in the oven for about 10 minutes, until golden brown.
To serve, ladle the soup into oven-safe bowls. Top each bowl with a slice of toasted bread and a generous amount of grated Gruyere and Parmesan cheese.
Place the filled bowls on a baking sheet and broil in the oven for 2-3 minutes, or until the cheese is bubbly and golden brown. Watch closely to prevent burning.
Let the soup cool slightly before serving.