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: mail.thread

Compute Method: _compute_message_attachment_count

Inputs Method Outputs
  • id
read_group_var = self.env['ir.attachment']._read_group([('res_id', 'in', self.ids), ('res_model', '=', self._name)],
                                                              groupby=['res_id'],
                                                              aggregates=['__count'])
attachment_count_dict = dict(read_group_var)
for record in self:
            record.message_attachment_count = attachment_count_dict.get(record.id, 0)

Back to entity