The gratin can be prepared up to 3-4 hours before baking.
Preheat the oven to 200C/gas 6/fan 180C. Heat 1 tbsp of the oil in a frying pan and fry the onion until starting to soften (about 5 minutes). Lift the onions out with a slotted spoon and place in an ovenproof dish.
Heat the remaining oil in the pan, then tip in the garlic, chilli, pumpkin chunks, chopped potatoes and sage and toss them together in the hot oil until lightly browned all over. (This takes 5-6 minutes.) Add to the dish containing the onion.
Scatter the two sorts of cheese over the vegetables, season and toss together until well mixed. Combine the stock and cream and pour over the vegetables.
Melt the butter in a frying pan and fry the breadcrumbs and walnuts together until lightly browned. Stir in the parsley and scatter the crumbly mixture over the top of the vegetables. Put in the oven for 25-30 minutes until bubbling and golden brown. Serve hot, with a chicory salad (see link, right).