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.

32 lines
1.1 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2016-2017 Compassion CH (http://www.compassion.ch)
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  4. from odoo import models, fields, api
  5. class MailTrackingEvent(models.Model):
  6. """ Push events to campaign_statistics
  7. """
  8. _inherit = 'mail.tracking.event'
  9. @api.model
  10. def process_delivered(self, tracking_email, metadata):
  11. res = super(MailTrackingEvent, self).process_delivered(
  12. tracking_email, metadata)
  13. mail_mail_stats = self.sudo().env['mail.mail.statistics'].search([
  14. ('mail_mail_id_int', '=', tracking_email.mail_id_int)])
  15. mail_mail_stats.write({
  16. 'sent': fields.Datetime.now()
  17. })
  18. return res
  19. @api.model
  20. def process_reject(self, tracking_email, metadata):
  21. res = super(MailTrackingEvent, self).process_reject(
  22. tracking_email, metadata)
  23. mail_mail_stats = self.sudo().env['mail.mail.statistics'].search([
  24. ('mail_mail_id_int', '=', tracking_email.mail_id_int)])
  25. mail_mail_stats.write({
  26. 'exception': fields.Datetime.now()
  27. })
  28. return res