+ def _message_auto_subscribe_notify(self, cr, uid, ids, partner_ids, context=None):
+ """ Send notifications to the partners automatically subscribed to the thread
+ Override this method if a custom behavior is needed about partners
+ that should be notified or messages that should be sent
+ """
+ # find first email message, set it as unread for auto_subscribe fields for them to have a notification
+ if partner_ids:
+ for record_id in ids:
+ message_obj = self.pool.get('mail.message')
+ msg_ids = message_obj.search(cr, SUPERUSER_ID, [
+ ('model', '=', self._name),
+ ('res_id', '=', record_id),
+ ('type', '=', 'email')], limit=1, context=context)
+ if not msg_ids:
+ msg_ids = message_obj.search(cr, SUPERUSER_ID, [
+ ('model', '=', self._name),
+ ('res_id', '=', record_id)], limit=1, context=context)
+ if msg_ids:
+ self.pool.get('mail.notification')._notify(cr, uid, msg_ids[0], partners_to_notify=partner_ids, context=context)
+