Heat the butter and 1 tbsp of the oil in a large ovenproof shallow casserole, skillet or frying pan until the butter has melted. Stir in the onions with a good pinch of salt. Cook over a medium high heat for 8 to 10 minutes until starting to brown, stirring occasionally. Mix in the thyme and sugar, then reduce the heat to low and cook for 1 hour, until deep golden and caramelised. Meanwhile, dissolve the stock pot in 500ml boiling water and set aside. Mix the 2 cheeses together in a bowl and set aside.
Once the onions have caramelised, scoop them out onto a plate. Heat the remaining 1 tbsp of oil in the same pan, then brown the meatballs over a medium high heat, turning regularly, for 8 to 10 minutes.
Meanwhile, preheat the oven to 200C/180C fan/gas 6. Stir the caramelised onions into the meatballs with the flour. Cook out for about 1 to 2 minutes, then pour in the wine and simmer for 2 to 3 minutes, until reduced. Add the stock, season with black pepper and a pinch of salt, then bring to the boil. Remove from the heat and stir in the orzo, ensuring it is submerged in the liquid.
Cover with a lid (or tightly with foil) and bake in the oven for 25 minutes. Remove from the oven, uncover, then top with the brioche slices, nestling them in slightly, and cheese. Return to the oven, uncovered, for 10 minutes until golden. Stand for 5 to 10 minutes before serving scattered with extra thyme leaves.