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.

29 lines
1.2 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2019 Therp BV <https://therp.nl>
  3. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  4. from odoo import http
  5. from odoo.http import request
  6. from odoo.addons.mail.controllers.main import MailController as _MailController
  7. class MailController(_MailController):
  8. @http.route()
  9. def read_subscription_data(self, res_model, follower_id):
  10. """Add custom notification data to subscriptions"""
  11. subtypes_list = super(MailController, self).read_subscription_data(
  12. res_model, follower_id,
  13. )
  14. follower = request.env['mail.followers'].browse(follower_id)
  15. for subtype_dict in subtypes_list:
  16. subtype = request.env['mail.message.subtype'].browse(
  17. subtype_dict['id']
  18. )
  19. subtype_dict['force_mail'] = 'default'
  20. if subtype in follower.force_mail_subtype_ids:
  21. subtype_dict['force_mail'] = 'force_yes'
  22. elif subtype in follower.force_nomail_subtype_ids:
  23. subtype_dict['force_mail'] = 'force_no'
  24. subtype_dict['force_own'] = (
  25. subtype in follower.force_own_subtype_ids
  26. )
  27. return subtypes_list