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.

41 lines
1.6 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2015 Therp BV <http://therp.nl>
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from odoo 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. def create(self, values):
  21. this = super(MailFollowers, self).create(values)
  22. for subtype in this.subtype_ids:
  23. if not subtype.res_model and\
  24. subtype.custom_notification_model_ids and\
  25. this.res_model not in\
  26. subtype.custom_notification_model_ids\
  27. .mapped('model'):
  28. continue
  29. if subtype.custom_notification_mail == 'force_yes':
  30. this.force_mail_subtype_ids += subtype
  31. if subtype.custom_notification_mail == 'force_no':
  32. this.force_nomail_subtype_ids += subtype
  33. if subtype.custom_notification_own:
  34. this.force_own_subtype_ids += subtype
  35. return this