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_vote_count

Inputs Method Outputs
  • id
read_group_res = self.env['forum.post.vote']._read_group([('post_id', 'in', self._ids)], ['post_id', 'vote'], ['__count'])
result = dict.fromkeys(self._ids, 0)
for post, vote, count in read_group_res:
            result[post.id] += count * int(vote)
for post in self:
            post.vote_count = result[post.id]

Back to entity