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.

49 lines
1.8 KiB

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