'Recompute stored function fields. The fields and records to
recompute have been determined by method :meth:`modified`.'

@api.model
def recompute(self):

    while self.env.has_todo():
        (field, recs) = self.env.get_todo()
        fs = self.env[field.model_name]._field_computed[field]
        ns = [f.name for f in fs if f.store]
        updates = defaultdict(set)
        for rec in recs.exists():
            vals = rec._convert_to_write({n: rec[n] for n in ns})
            updates[frozendict(vals)].add(rec.id)
        with recs.env.norecompute():
            for (vals, ids) in updates.iteritems():
                recs.browse(ids)._write(dict(vals))
        map(recs._recompute_done, fs)
