Browse Source

Merge pull request #226 from Tecnativa/9.0-mail_tracking_mailgun-backport_10.0

[FIX] mail_tracking_mailgun: Backport some fixes
pull/233/head
Pedro M. Baeza 7 years ago
committed by GitHub
parent
commit
605e626faa
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      mail_tracking_mailgun/models/mail_tracking_email.py
  2. 3
      mail_tracking_mailgun/models/res_partner.py

6
mail_tracking_mailgun/models/mail_tracking_email.py

@ -9,7 +9,7 @@ import json
import requests
from datetime import datetime
from openerp import _, api, fields, models
from openerp.exceptions import ValidationError
from openerp.exceptions import UserError, ValidationError
import logging
_logger = logging.getLogger(__name__)
@ -221,6 +221,8 @@ class MailTrackingEmail(models.Model):
"""
api_key, api_url, domain, validation_key = self._mailgun_values()
for tracking in self:
if not tracking.mail_message_id:
raise UserError(_('There is no tracked message!'))
message_id = tracking.mail_message_id.message_id.replace(
"<", "").replace(">", "")
res = requests.get(
@ -242,7 +244,7 @@ class MailTrackingEmail(models.Model):
if not self.env['mail.tracking.event'].search(
[('mailgun_id', '=', item["id"])]):
mapped_event_type = self._mailgun_event_type_mapping.get(
item["event"]) or False
item["event"], item["event"])
metadata = self._mailgun_metadata(
mapped_event_type, item, {})
tracking.event_create(mapped_event_type, metadata)

3
mail_tracking_mailgun/models/res_partner.py

@ -30,7 +30,8 @@ class ResPartner(models.Model):
body = _('Email has been bounced: %s\n'
'Reason: %s\n'
'Event: %s') % (partner.email, reason,
event['Message-Id'] or '')
event and event.get('Message-Id',
_('unknown')))
partner.message_post(body=body)
@api.multi

Loading…
Cancel
Save