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.

53 lines
2.0 KiB

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