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.forum

Compute Method: _compute_last_post_id

Inputs Method Outputs
  • id
last_forums_posts = self.env['forum.post']._read_group(
            [('forum_id', 'in', self.ids), ('parent_id', '=', False), ('state', '=', 'active')],
            groupby=['forum_id'], aggregates=['id:max'],
        )
forum_to_last_post_id = {forum.id: last_post_id for forum, last_post_id in last_forums_posts}
for forum in self:
            forum.last_post_id = forum_to_last_post_id.get(forum.id, False)

Back to entity