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.

54 lines
2.0 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com>
  3. # Copyright 2017 Vicent Cubells - <vicent.cubells@tecnativa.com>
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  5. from odoo import api, fields, models
  6. class MailTrackingEvent(models.Model):
  7. _inherit = "mail.tracking.event"
  8. mass_mailing_id = fields.Many2one(
  9. string="Mass mailing", comodel_name='mail.mass_mailing', readonly=True,
  10. related='tracking_email_id.mass_mailing_id', store=True)
  11. @api.model
  12. def process_open(self, tracking_email, metadata):
  13. res = super(MailTrackingEvent, self).process_open(
  14. tracking_email, metadata)
  15. mail_mail_stats = self.sudo().env['mail.mail.statistics']
  16. mail_mail_stats.set_opened(mail_mail_ids=[tracking_email.mail_id_int])
  17. return res
  18. def _tracking_set_bounce(self, tracking_email, metadata):
  19. mail_mail_stats = self.sudo().env['mail.mail.statistics']
  20. mail_mail_stats.set_bounced(mail_mail_ids=[tracking_email.mail_id_int])
  21. @api.model
  22. def process_hard_bounce(self, tracking_email, metadata):
  23. res = super(MailTrackingEvent, self).process_hard_bounce(
  24. tracking_email, metadata)
  25. self._tracking_set_bounce(tracking_email, metadata)
  26. return res
  27. @api.model
  28. def process_soft_bounce(self, tracking_email, metadata):
  29. res = super(MailTrackingEvent, self).process_soft_bounce(
  30. tracking_email, metadata)
  31. self._tracking_set_bounce(tracking_email, metadata)
  32. return res
  33. @api.model
  34. def process_reject(self, tracking_email, metadata):
  35. res = super(MailTrackingEvent, self).process_reject(
  36. tracking_email, metadata)
  37. self._tracking_set_bounce(tracking_email, metadata)
  38. return res
  39. @api.model
  40. def process_spam(self, tracking_email, metadata):
  41. res = super(MailTrackingEvent, self).process_spam(
  42. tracking_email, metadata)
  43. self._tracking_set_bounce(tracking_email, metadata)
  44. return res