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.

25 lines
1.0 KiB

  1. # Copyright 2019 Eficent Business and IT Consulting Services, S.L.
  2. # Copyright 2019 Aleph Objects, Inc.
  3. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
  4. from odoo import api, models
  5. class MailThread(models.AbstractModel):
  6. _inherit = 'mail.thread'
  7. @api.multi
  8. def message_auto_subscribe(self, updated_fields, values=None):
  9. super(MailThread, self).message_auto_subscribe(updated_fields,
  10. values=values)
  11. user_field_lst = self._message_get_auto_subscribe_fields(
  12. updated_fields)
  13. to_add_users = self.env['res.users'].sudo().browse(
  14. [values[name] for name in user_field_lst if values.get(name)]
  15. ).filtered(lambda u: u.partner_id.active)
  16. user_pids = [user.partner_id.id for user in to_add_users
  17. if user == self.env.user and
  18. user.notification_type == 'email']
  19. if user_pids:
  20. self._message_auto_subscribe_notify(user_pids)
  21. return True