[10.0][FIX] mail_tracking_mailgun: Avoid key dict errors
This commit is contained in:
parent
11f1664f6f
commit
112ed9a274
@ -7,7 +7,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Mail tracking for Mailgun",
|
"name": "Mail tracking for Mailgun",
|
||||||
"summary": "Mail tracking and Mailgun webhooks integration",
|
"summary": "Mail tracking and Mailgun webhooks integration",
|
||||||
"version": "10.0.1.1.0",
|
"version": "10.0.1.1.1",
|
||||||
"category": "Social Network",
|
"category": "Social Network",
|
||||||
"website": "https://odoo-community.org/",
|
"website": "https://odoo-community.org/",
|
||||||
"author": "Tecnativa, "
|
"author": "Tecnativa, "
|
||||||
|
@ -9,7 +9,7 @@ import json
|
|||||||
import requests
|
import requests
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from odoo import _, api, fields, models
|
from odoo import _, api, fields, models
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import UserError, ValidationError
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
@ -221,6 +221,8 @@ class MailTrackingEmail(models.Model):
|
|||||||
"""
|
"""
|
||||||
api_key, api_url, domain, validation_key = self._mailgun_values()
|
api_key, api_url, domain, validation_key = self._mailgun_values()
|
||||||
for tracking in self:
|
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(
|
message_id = tracking.mail_message_id.message_id.replace(
|
||||||
"<", "").replace(">", "")
|
"<", "").replace(">", "")
|
||||||
res = requests.get(
|
res = requests.get(
|
||||||
@ -242,7 +244,7 @@ class MailTrackingEmail(models.Model):
|
|||||||
if not self.env['mail.tracking.event'].search(
|
if not self.env['mail.tracking.event'].search(
|
||||||
[('mailgun_id', '=', item["id"])]):
|
[('mailgun_id', '=', item["id"])]):
|
||||||
mapped_event_type = self._mailgun_event_type_mapping.get(
|
mapped_event_type = self._mailgun_event_type_mapping.get(
|
||||||
item["event"]) or False
|
item["event"], item["event"])
|
||||||
metadata = self._mailgun_metadata(
|
metadata = self._mailgun_metadata(
|
||||||
mapped_event_type, item, {})
|
mapped_event_type, item, {})
|
||||||
tracking.event_create(mapped_event_type, metadata)
|
tracking.event_create(mapped_event_type, metadata)
|
||||||
|
@ -8,8 +8,8 @@
|
|||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from openerp import _, api, models
|
from odoo import _, api, models
|
||||||
from openerp.exceptions import UserError
|
from odoo.exceptions import UserError
|
||||||
|
|
||||||
|
|
||||||
class ResPartner(models.Model):
|
class ResPartner(models.Model):
|
||||||
@ -30,7 +30,7 @@ class ResPartner(models.Model):
|
|||||||
body = _('Email has been bounced: %s\n'
|
body = _('Email has been bounced: %s\n'
|
||||||
'Reason: %s\n'
|
'Reason: %s\n'
|
||||||
'Event: %s') % (partner.email, reason,
|
'Event: %s') % (partner.email, reason,
|
||||||
event['Message-Id'] or '')
|
event.get('Message-Id', _('unknown')))
|
||||||
partner.message_post(body=body)
|
partner.message_post(body=body)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user