Melt the butter in a large heavy bottomed pan over medium heat. When the butter has melted add onions and salt. Cook the onions stirring occasionally until they have browned. This will take about 30 minutes.
About halfway through the onions browning add the garlic and bay leaves. Add the dry Sherry and scrape up the browned bits on the bottom of the pan. When the Sherry has evaporated add the flour, and stir well. Cook the flour into the onions until you can detect a faint smell of pie dough. This will take about five minutes.
The flour must cook thoroughly. Add the beef stock and turn down the heat to a simmer. When the soup has heated through you may serve the soup. A serving suggestion is to toast a baguette slice on both sides and add it to a heat proof bowl that has been filled with the soup. Layer the bread upon the soup, and add a couple of tablespoons of cheese to the bowl. Place the bowl under a broiler until the cheese just begins to brown.