'Remove the needaction from messages for the current partner.'

@api.multi
def set_message_done(self):

    partner_id = self.env.user.partner_id
    delete_mode = (not self.env.user.share)
    notifications = self.env['mail.notification'].sudo().search([('mail_message_id', 'in', self.ids), ('res_partner_id', '=', partner_id.id), ('is_read', '=', False)])
    if (not notifications):
        return
    groups = []
    messages = notifications.mapped('mail_message_id')
    current_channel_ids = messages[0].channel_ids
    current_group = []
    for record in messages:
        if (record.channel_ids == current_channel_ids):
            current_group.append(record.id)
        else:
            groups.append((current_group, current_channel_ids))
            current_group = [record.id]
            current_channel_ids = record.channel_ids
    groups.append((current_group, current_channel_ids))
    current_group = [record.id]
    current_channel_ids = record.channel_ids
    if delete_mode:
        notifications.unlink()
    else:
        notifications.write({'is_read': True})
    for (msg_ids, channel_ids) in groups:
        notification = {'type': 'mark_as_read', 'message_ids': msg_ids, 'channel_ids': [c.id for c in channel_ids]}
        self.env['bus.bus'].sendone((self._cr.dbname, 'res.partner', partner_id.id), notification)
