Wash the dried beans, soak in water for 8 hours, then strain and wash again. Put the beans into a pan with the onions, olive oil, water, sugar and salt. Cover and cook on a low heat for 40 minutes or until the beans break up. While still hot strain and purée through a coarse sieve or in a food processor – the mixture should have the consistency of thick yoghurt.
Put the purée in a pan o