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.member
Compute Method: _compute_message_unread
| Inputs | Method | Outputs |
|---|---|---|
|
if self.ids:
self.env['mail.message'].flush_model()
- self.flush_recordset(['channel_id', 'seen_message_id'])
+ self.flush_recordset(['channel_id', 'new_message_separator'])
self.env.cr.execute("""
SELECT count(mail_message.id) AS count,
discuss_channel_member.id
FROM mail_message
INNER JOIN discuss_channel_member
ON discuss_channel_member.channel_id = mail_message.res_id
WHERE mail_message.model = 'discuss.channel'
AND mail_message.message_type NOT IN ('notification', 'user_notification')
- AND (
- mail_message.id > discuss_channel_member.seen_message_id
- OR discuss_channel_member.seen_message_id IS NULL
- )
+ AND mail_message.id >= discuss_channel_member.new_message_separator
AND discuss_channel_member.id IN %(ids)s
GROUP BY discuss_channel_member.id
""", {'ids': tuple(self.ids)})
unread_counter_by_member = {res['id']: res['count'] for res in self.env.cr.dictfetchall()}
for member in self:
member.message_unread_counter = unread_counter_by_member.get(member.id)
else:
self.message_unread_counter = 0
|
|
