You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.4 KiB

  1. # -*- coding: utf-8 -*-
  2. # © 2015 Therp BV <http://therp.nl>
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from openerp import api, models
  5. class MailNotification(models.Model):
  6. _inherit = 'mail.notification'
  7. @api.multi
  8. def get_partners_to_email(self, message):
  9. partner_ids = super(MailNotification, self)\
  10. .get_partners_to_email(message)
  11. for this in self:
  12. follower = self.env['mail.followers'].search([
  13. ('res_model', '=', message.model),
  14. ('res_id', '=', message.res_id),
  15. ('partner_id', '=', this.partner_id.id),
  16. '|', '|',
  17. ('force_nomail_subtype_ids', '=', message.subtype_id.id),
  18. ('force_mail_subtype_ids', '=', message.subtype_id.id),
  19. ('force_own_subtype_ids', '=', message.subtype_id.id),
  20. ])
  21. if not follower:
  22. continue
  23. if (message.subtype_id in follower.force_mail_subtype_ids or
  24. message.subtype_id in follower.force_own_subtype_ids) and\
  25. this.partner_id.id not in partner_ids:
  26. partner_ids.append(this.partner_id.id)
  27. if message.subtype_id in follower.force_nomail_subtype_ids and\
  28. this.partner_id.id in partner_ids:
  29. partner_ids.remove(this.partner_id.id)
  30. return partner_ids