diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index af6a5cdbb2a..147f4f2d02c 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -330,19 +330,23 @@ class mail_message(osv.Model): """ Add the related record followers to the destination partner_ids. Call mail_notification.notify to manage the email sending """ + followers_obj = self.pool.get('mail.followers') message = self.browse(cr, uid, newid, context=context) + followers_ids = followers_obj.search(cr, uid, ['&', ('res_model', '=', message.model), ('res_id', 'in', [message.res_id])], context=context) + # check with subtype + is_subtype = False + + for subscription in followers_obj.browse(cr, uid, followers_ids, context=context): + if subtype_id: + if subtype_id in [subtype.id for subtype in subscription.subtype_ids]: + is_subtype = True partners_to_notify = [] # add all partner_ids of the message - is_subtype = False if message.partner_ids: for partner in message.partner_ids: if partner.id not in partners_to_notify: - if subtype_id: - if subtype_id in [subtype.id for subtype in subscription.subtype_ids]: - is_subtype = False + if(is_subtype): partners_to_notify.append(partner.id) - else: - partners_to_notify.append(partner.id) # add all followers and set them as partner_ids if message.model and message.res_id: modobj = self.pool.get(message.model) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 28286783f39..a100a8f1b84 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -652,7 +652,6 @@ class mail_thread(osv.Model): :param partner_ids: a list of partner_ids to subscribe :param return: new value of followers, for Chatter """ - print "message_subscribe",subtype_ids self.write(cr, uid, ids, {'message_follower_ids': [(4, pid) for pid in partner_ids]}, context=context) if not subtype_ids: subtype_obj = self.pool.get('mail.message.subtype')