'Check the cache consistency.'

def check_cache(self):

    from odoo.fields import SpecialValue
    cache_dump = dict(((field, dict(field_cache)) for (field, field_cache) in self.cache.iteritems()))
    self.invalidate_all()
    invalids = []
    for (field, field_dump) in cache_dump.iteritems():
        ids = filter(None, field_dump)
        records = self[field.model_name].browse(ids)
        for record in records:
            try:
                cached = field_dump[record.id]
                cached = (cached.get() if isinstance(cached, SpecialValue) else cached)
                value = field.convert_to_record(cached, record)
                fetched = record[field.name]
                if (fetched != value):
                    info = {'cached': value, 'fetched': fetched}
                    invalids.append((field, record, info))
            except (AccessError, MissingError):
                pass
    if invalids:
        raise UserError(('Invalid    cache    for    fields\n' + pformat(invalids)))
