Peel and thinly slice onions (about 10 cups).
Heat 3 tablespoons of olive oil in a large pot over medium heat.
Add onions and toss to coat.
Cook, stirring often, until softened (15-20 minutes).
Increase heat to medium-high, add 1 tablespoon olive oil and butter.
Stir and cook until onions start to brown (20-40 minutes).
Sprinkle with sugar and 1 teaspoon salt, and continue cooking until deeply browned (10-15 minutes).
Deglaze the pot with wine or vermouth, scraping up browned bits.
Add stock, bay leaves, and thyme.
Simmer for 30 minutes.
Stir in minced garlic, season with salt and pepper, and discard the bay leaves.
Add brandy if desired.
Meanwhile, preheat oven to 450°F.
Brush both sides of bread slices with olive oil and toast until golden (5-7 minutes).
Flip, sprinkle with Gruyère and Parmesan, then bake until cheese is bubbly and browned and serve with the soup.