Heat the oil in a large pan, add the onions, stir and cover. Cook over a gentle heat for 10 minutes, stirring occasionally until soft. Remove the lid and stir and cook for a further 7 minutes. Add the garlic and sugar and cook for 2 minutes until caramelised. Stir in the flour and cook stirring for 1 minute. Add the wine whisking constantly. Boil rapidly for 2 minutes, add the stock and bay leaves and boil for a further 10 minutes until reduced to a thickened coating consistency.