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.

42 lines
1.7 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, fields, models
  5. class MailFollowers(models.Model):
  6. _inherit = 'mail.followers'
  7. force_mail_subtype_ids = fields.Many2many(
  8. 'mail.message.subtype', 'mail_followers_force_mail_rel',
  9. 'mail_followers_id', 'mail_message_subtype_id',
  10. string='Force mails from subtype')
  11. force_nomail_subtype_ids = fields.Many2many(
  12. 'mail.message.subtype', 'mail_followers_force_nomail_rel',
  13. 'mail_followers_id', 'mail_message_subtype_id',
  14. string='Force no mails from subtype')
  15. force_own_subtype_ids = fields.Many2many(
  16. 'mail.message.subtype', 'mail_followers_force_own_rel',
  17. 'mail_followers_id', 'mail_message_subtype_id',
  18. string='Force own mails from subtype')
  19. @api.model
  20. @api.returns('self', lambda x: x.id)
  21. def create(self, values):
  22. this = super(MailFollowers, self).create(values)
  23. for subtype in this.subtype_ids:
  24. if not subtype.res_model and\
  25. subtype.custom_notification_model_ids and\
  26. this.res_model not in\
  27. subtype.custom_notification_model_ids\
  28. .mapped('model'):
  29. continue
  30. if subtype.custom_notification_mail == 'force_yes':
  31. this.force_mail_subtype_ids += subtype
  32. if subtype.custom_notification_mail == 'force_no':
  33. this.force_nomail_subtype_ids += subtype
  34. if subtype.custom_notification_own:
  35. this.force_own_subtype_ids += subtype
  36. return this