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

View 19.0 View 20.0
Inputs Method Outputs
  • id
votes = self.env['forum.post.vote'].sudo().search_read([('post_id', 'in', self._ids), ('user_id', '=', self.env.uid)], ['vote', 'post_id'])
- mapped_vote = dict([(v['post_id'][0], v['vote']) for v in votes])
+ mapped_vote = {v['post_id'][0]: v['vote'] for v in votes}
for vote in self:
            vote.user_vote = mapped_vote.get(vote.id, 0)
  • user_vote

Back to entity