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

Module: Discuss

Entity: discuss.channel

Compute Method: _compute_message_count

Inputs Method Outputs
  • id
read_group_res = self.env["mail.message"]._read_group(
            domain=[
                ("model", "=", "discuss.channel"),
                ("res_id", "in", self.ids),
                ("message_type", "not in", ["user_notification", "notification"])
            ], groupby=["res_id"], aggregates=["__count"]
        )
message_count_by_channel_id = dict(read_group_res)
for channel in self:
            channel.message_count = message_count_by_channel_id.get(channel.id, 0)

Back to entity