Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Forum

Entity: forum.post

Compute Method: _compute_user_vote

Inputs Method Outputs
  • id
votes = self.env['forum.post.vote'].search_read([('post_id', 'in', self._ids), ('user_id', '=', self._uid)], ['vote', 'post_id'])
mapped_vote = dict([(v['post_id'][0], v['vote']) for v in votes])
for vote in self:
            vote.user_vote = mapped_vote.get(vote.id, 0)

Back to entity