2018-03-19 16:41:26 +01:00
|
|
|
# Copyright 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com>
|
2016-06-14 17:22:17 +02:00
|
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
|
|
|
|
|
|
|
import logging
|
|
|
|
import re
|
2019-11-18 11:46:59 +01:00
|
|
|
import time
|
|
|
|
import urllib.parse
|
2019-10-17 03:28:42 +02:00
|
|
|
import uuid
|
2016-06-14 17:22:17 +02:00
|
|
|
from datetime import datetime
|
|
|
|
|
2019-11-18 11:34:02 +01:00
|
|
|
from odoo import api, fields, models, tools
|
2016-06-14 17:22:17 +02:00
|
|
|
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
2016-09-09 13:29:58 +02:00
|
|
|
EVENT_OPEN_DELTA = 10 # seconds
|
|
|
|
EVENT_CLICK_DELTA = 5 # seconds
|
|
|
|
|
2016-06-14 17:22:17 +02:00
|
|
|
|
|
|
|
class MailTrackingEmail(models.Model):
|
|
|
|
_name = "mail.tracking.email"
|
2019-11-18 11:46:59 +01:00
|
|
|
_order = "time desc"
|
|
|
|
_rec_name = "display_name"
|
|
|
|
_description = "MailTracking email"
|
2016-06-14 17:22:17 +02:00
|
|
|
|
2016-10-14 15:42:29 +02:00
|
|
|
# This table is going to grow fast and to infinite, so we index:
|
|
|
|
# - name: Search in tree view
|
|
|
|
# - time: default order fields
|
|
|
|
# - recipient_address: Used for email_store calculation (non-store)
|
|
|
|
# - state: Search and group_by in tree view
|
2016-06-14 17:22:17 +02:00
|
|
|
name = fields.Char(string="Subject", readonly=True, index=True)
|
|
|
|
display_name = fields.Char(
|
2019-11-18 11:46:59 +01:00
|
|
|
string="Display name",
|
|
|
|
readonly=True,
|
|
|
|
store=True,
|
|
|
|
compute="_compute_tracking_display_name",
|
|
|
|
)
|
2016-06-14 17:22:17 +02:00
|
|
|
timestamp = fields.Float(
|
2019-11-18 11:34:02 +01:00
|
|
|
string="UTC timestamp", readonly=True, digits="MailTracking Timestamp"
|
|
|
|
)
|
2016-10-14 15:42:29 +02:00
|
|
|
time = fields.Datetime(string="Time", readonly=True, index=True)
|
2016-06-14 17:22:17 +02:00
|
|
|
date = fields.Date(
|
2019-11-18 11:46:59 +01:00
|
|
|
string="Date", readonly=True, compute="_compute_date", store=True
|
|
|
|
)
|
2016-06-14 17:22:17 +02:00
|
|
|
mail_message_id = fields.Many2one(
|
2019-11-18 11:46:59 +01:00
|
|
|
string="Message", comodel_name="mail.message", readonly=True, index=True
|
|
|
|
)
|
|
|
|
mail_id = fields.Many2one(string="Email", comodel_name="mail.mail", readonly=True)
|
2016-06-14 17:22:17 +02:00
|
|
|
partner_id = fields.Many2one(
|
2019-11-18 11:46:59 +01:00
|
|
|
string="Partner", comodel_name="res.partner", readonly=True
|
|
|
|
)
|
|
|
|
recipient = fields.Char(string="Recipient email", readonly=True)
|
2016-06-14 17:22:17 +02:00
|
|
|
recipient_address = fields.Char(
|
2019-11-18 11:46:59 +01:00
|
|
|
string="Recipient email address",
|
|
|
|
readonly=True,
|
|
|
|
store=True,
|
|
|
|
compute="_compute_recipient_address",
|
|
|
|
index=True,
|
|
|
|
)
|
|
|
|
sender = fields.Char(string="Sender email", readonly=True)
|
|
|
|
state = fields.Selection(
|
|
|
|
[
|
|
|
|
("error", "Error"),
|
|
|
|
("deferred", "Deferred"),
|
|
|
|
("sent", "Sent"),
|
|
|
|
("delivered", "Delivered"),
|
|
|
|
("opened", "Opened"),
|
|
|
|
("rejected", "Rejected"),
|
|
|
|
("spam", "Spam"),
|
|
|
|
("unsub", "Unsubscribed"),
|
|
|
|
("bounced", "Bounced"),
|
|
|
|
("soft-bounced", "Soft bounced"),
|
|
|
|
],
|
|
|
|
string="State",
|
|
|
|
index=True,
|
|
|
|
readonly=True,
|
|
|
|
default=False,
|
2016-06-14 17:22:17 +02:00
|
|
|
help=" * The 'Error' status indicates that there was an error "
|
2019-11-18 11:46:59 +01:00
|
|
|
"when trying to sent the email, for example, "
|
|
|
|
"'No valid recipient'\n"
|
|
|
|
" * The 'Sent' status indicates that message was succesfully "
|
|
|
|
"sent via outgoing email server (SMTP).\n"
|
|
|
|
" * The 'Delivered' status indicates that message was "
|
|
|
|
"succesfully delivered to recipient Mail Exchange (MX) server.\n"
|
|
|
|
" * The 'Opened' status indicates that message was opened or "
|
|
|
|
"clicked by recipient.\n"
|
|
|
|
" * The 'Rejected' status indicates that recipient email "
|
|
|
|
"address is blacklisted by outgoing email server (SMTP). "
|
|
|
|
"It is recomended to delete this email address.\n"
|
|
|
|
" * The 'Spam' status indicates that outgoing email "
|
|
|
|
"server (SMTP) consider this message as spam.\n"
|
|
|
|
" * The 'Unsubscribed' status indicates that recipient has "
|
|
|
|
"requested to be unsubscribed from this message.\n"
|
|
|
|
" * The 'Bounced' status indicates that message was bounced "
|
|
|
|
"by recipient Mail Exchange (MX) server.\n"
|
|
|
|
" * The 'Soft bounced' status indicates that message was soft "
|
|
|
|
"bounced by recipient Mail Exchange (MX) server.\n",
|
|
|
|
)
|
|
|
|
error_smtp_server = fields.Char(string="Error SMTP server", readonly=True)
|
|
|
|
error_type = fields.Char(string="Error type", readonly=True)
|
|
|
|
error_description = fields.Char(string="Error description", readonly=True)
|
|
|
|
bounce_type = fields.Char(string="Bounce type", readonly=True)
|
|
|
|
bounce_description = fields.Char(string="Bounce description", readonly=True)
|
2016-06-14 17:22:17 +02:00
|
|
|
tracking_event_ids = fields.One2many(
|
2019-11-18 11:46:59 +01:00
|
|
|
string="Tracking events",
|
|
|
|
comodel_name="mail.tracking.event",
|
|
|
|
inverse_name="tracking_email_id",
|
|
|
|
readonly=True,
|
|
|
|
)
|
2019-10-17 03:28:42 +02:00
|
|
|
# Token isn't generated here to have compatibility with older trackings.
|
|
|
|
# New trackings have token and older not
|
2019-11-18 11:46:59 +01:00
|
|
|
token = fields.Char(
|
|
|
|
string="Security Token",
|
|
|
|
readonly=True,
|
|
|
|
default=lambda s: uuid.uuid4().hex,
|
|
|
|
groups="base.group_system",
|
|
|
|
)
|
2019-10-17 03:28:42 +02:00
|
|
|
|
|
|
|
@api.model_create_multi
|
|
|
|
def create(self, vals_list):
|
|
|
|
records = super().create(vals_list)
|
2019-11-18 11:46:59 +01:00
|
|
|
failed_states = self.env["mail.message"].get_failed_states()
|
|
|
|
records.filtered(lambda one: one.state in failed_states).mapped(
|
|
|
|
"mail_message_id"
|
|
|
|
).write({"mail_tracking_needs_action": True})
|
2019-10-17 03:28:42 +02:00
|
|
|
return records
|
2016-06-14 17:22:17 +02:00
|
|
|
|
2019-07-05 14:20:27 +02:00
|
|
|
def write(self, vals):
|
2019-10-17 03:28:42 +02:00
|
|
|
super().write(vals)
|
2019-11-18 11:46:59 +01:00
|
|
|
state = vals.get("state")
|
|
|
|
if state and state in self.env["mail.message"].get_failed_states():
|
|
|
|
self.mapped("mail_message_id").write({"mail_tracking_needs_action": True})
|
2019-07-05 14:20:27 +02:00
|
|
|
|
2016-06-14 17:22:17 +02:00
|
|
|
@api.model
|
2016-10-14 15:42:29 +02:00
|
|
|
def email_is_bounced(self, email):
|
2018-11-05 17:26:01 +01:00
|
|
|
if not email:
|
|
|
|
return False
|
|
|
|
res = self._email_last_tracking_state(email)
|
2019-11-18 11:46:59 +01:00
|
|
|
return res and res[0].get("state", "") in {
|
|
|
|
"rejected",
|
|
|
|
"error",
|
|
|
|
"spam",
|
|
|
|
"bounced",
|
|
|
|
}
|
2018-11-05 17:26:01 +01:00
|
|
|
|
|
|
|
@api.model
|
|
|
|
def _email_last_tracking_state(self, email):
|
2019-11-18 11:46:59 +01:00
|
|
|
return self.search_read(
|
|
|
|
[("recipient_address", "=", email.lower())],
|
|
|
|
["state"],
|
|
|
|
limit=1,
|
|
|
|
order="time DESC",
|
|
|
|
)
|
2016-06-14 17:22:17 +02:00
|
|
|
|
2016-09-09 18:31:25 +02:00
|
|
|
@api.model
|
|
|
|
def email_score_from_email(self, email):
|
2018-09-06 11:24:20 +02:00
|
|
|
if not email:
|
2019-11-18 11:46:59 +01:00
|
|
|
return 0.0
|
|
|
|
data = self.read_group(
|
|
|
|
[("recipient_address", "=", email.lower())],
|
|
|
|
["recipient_address", "state"],
|
|
|
|
["state"],
|
|
|
|
)
|
|
|
|
mapped_data = {state["state"]: state["state_count"] for state in data}
|
2018-09-06 11:24:20 +02:00
|
|
|
return self.with_context(mt_states=mapped_data).email_score()
|
2016-10-14 15:42:29 +02:00
|
|
|
|
|
|
|
@api.model
|
|
|
|
def _email_score_weights(self):
|
|
|
|
"""Default email score weights. Ready to be inherited"""
|
|
|
|
return {
|
2019-11-18 11:46:59 +01:00
|
|
|
"error": -50.0,
|
|
|
|
"rejected": -25.0,
|
|
|
|
"spam": -25.0,
|
|
|
|
"bounced": -25.0,
|
|
|
|
"soft-bounced": -10.0,
|
|
|
|
"unsub": -10.0,
|
|
|
|
"delivered": 1.0,
|
|
|
|
"opened": 5.0,
|
2016-10-14 15:42:29 +02:00
|
|
|
}
|
2016-09-09 18:31:25 +02:00
|
|
|
|
2016-06-14 17:22:17 +02:00
|
|
|
def email_score(self):
|
2016-10-14 15:42:29 +02:00
|
|
|
"""Default email score algorimth. Ready to be inherited
|
2018-09-06 11:24:20 +02:00
|
|
|
It can receive a recordset or mapped states dictionary via context.
|
2016-10-14 15:42:29 +02:00
|
|
|
Must return a value beetwen 0.0 and 100.0
|
|
|
|
- Bad reputation: Value between 0 and 50.0
|
|
|
|
- Unknown reputation: Value 50.0
|
|
|
|
- Good reputation: Value between 50.0 and 100.0
|
|
|
|
"""
|
|
|
|
weights = self._email_score_weights()
|
2016-06-14 17:22:17 +02:00
|
|
|
score = 50.0
|
2019-11-18 11:46:59 +01:00
|
|
|
states = self.env.context.get("mt_states", False)
|
2018-09-06 11:24:20 +02:00
|
|
|
if states:
|
|
|
|
for state in states.keys():
|
|
|
|
score += weights.get(state, 0.0) * states[state]
|
|
|
|
else:
|
|
|
|
for tracking in self:
|
|
|
|
score += weights.get(tracking.state, 0.0)
|
2016-06-14 17:22:17 +02:00
|
|
|
if score > 100.0:
|
|
|
|
score = 100.0
|
2016-10-14 15:42:29 +02:00
|
|
|
elif score < 0.0:
|
|
|
|
score = 0.0
|
2016-06-14 17:22:17 +02:00
|
|
|
return score
|
|
|
|
|
2019-11-18 11:46:59 +01:00
|
|
|
@api.depends("recipient")
|
2016-06-14 17:22:17 +02:00
|
|
|
def _compute_recipient_address(self):
|
|
|
|
for email in self:
|
2019-11-18 11:46:59 +01:00
|
|
|
is_empty_recipient = not email.recipient or "<False>" in email.recipient
|
2019-10-17 03:28:42 +02:00
|
|
|
if not is_empty_recipient:
|
2019-11-18 11:46:59 +01:00
|
|
|
matches = re.search(r"<(.*@.*)>", email.recipient)
|
2016-10-24 13:35:45 +02:00
|
|
|
if matches:
|
|
|
|
email.recipient_address = matches.group(1).lower()
|
|
|
|
else:
|
|
|
|
email.recipient_address = email.recipient.lower()
|
2016-06-14 17:22:17 +02:00
|
|
|
else:
|
2016-10-24 13:35:45 +02:00
|
|
|
email.recipient_address = False
|
2016-06-14 17:22:17 +02:00
|
|
|
|
2019-11-18 11:46:59 +01:00
|
|
|
@api.depends("name", "recipient")
|
2016-10-14 21:53:04 +02:00
|
|
|
def _compute_tracking_display_name(self):
|
2016-06-14 17:22:17 +02:00
|
|
|
for email in self:
|
2019-11-18 11:46:59 +01:00
|
|
|
parts = [email.name or ""]
|
2016-06-14 17:22:17 +02:00
|
|
|
if email.recipient:
|
|
|
|
parts.append(email.recipient)
|
2019-11-18 11:46:59 +01:00
|
|
|
email.display_name = " - ".join(parts)
|
2016-06-14 17:22:17 +02:00
|
|
|
|
2019-11-18 11:46:59 +01:00
|
|
|
@api.depends("time")
|
2016-06-14 17:22:17 +02:00
|
|
|
def _compute_date(self):
|
|
|
|
for email in self:
|
2019-11-18 11:46:59 +01:00
|
|
|
email.date = fields.Date.to_string(fields.Date.from_string(email.time))
|
2016-06-14 17:22:17 +02:00
|
|
|
|
|
|
|
def _get_mail_tracking_img(self):
|
2019-11-18 11:46:59 +01:00
|
|
|
m_config = self.env["ir.config_parameter"]
|
|
|
|
base_url = m_config.get_param("mail_tracking.base.url") or m_config.get_param(
|
|
|
|
"web.base.url"
|
|
|
|
)
|
2019-10-17 03:28:42 +02:00
|
|
|
if self.token:
|
|
|
|
path_url = (
|
2019-11-18 11:46:59 +01:00
|
|
|
"mail/tracking/open/%(db)s/%(tracking_email_id)s/%(token)s/"
|
|
|
|
"blank.gif"
|
|
|
|
% {
|
|
|
|
"db": self.env.cr.dbname,
|
|
|
|
"tracking_email_id": self.id,
|
|
|
|
"token": self.token,
|
|
|
|
}
|
|
|
|
)
|
2019-10-17 03:28:42 +02:00
|
|
|
else:
|
|
|
|
# This is here for compatibility with older records
|
2019-11-18 11:46:59 +01:00
|
|
|
path_url = "mail/tracking/open/{db}/{tracking_email_id}/blank.gif".format(
|
|
|
|
db=self.env.cr.dbname, tracking_email_id=self.id
|
|
|
|
)
|
2018-03-19 16:41:26 +01:00
|
|
|
track_url = urllib.parse.urljoin(base_url, path_url)
|
2016-06-14 17:22:17 +02:00
|
|
|
return (
|
|
|
|
'<img src="%(url)s" alt="" '
|
2019-11-18 11:46:59 +01:00
|
|
|
'data-odoo-tracking-email="%(tracking_email_id)s"/>'
|
|
|
|
% {"url": track_url, "tracking_email_id": self.id}
|
|
|
|
)
|
2016-06-14 17:22:17 +02:00
|
|
|
|
2016-11-25 19:03:11 +01:00
|
|
|
def _partners_email_bounced_set(self, reason, event=None):
|
|
|
|
recipients = []
|
|
|
|
if event and event.recipient_address:
|
|
|
|
recipients.append(event.recipient_address)
|
|
|
|
else:
|
2019-11-18 11:46:59 +01:00
|
|
|
recipients = [x for x in self.mapped("recipient_address") if x]
|
2016-11-25 19:03:11 +01:00
|
|
|
for recipient in recipients:
|
2019-11-18 11:46:59 +01:00
|
|
|
self.env["res.partner"].search(
|
|
|
|
[("email", "=ilike", recipient)]
|
|
|
|
).email_bounced_set(self, reason, event=event)
|
2016-10-14 15:42:29 +02:00
|
|
|
|
2016-06-14 17:22:17 +02:00
|
|
|
def smtp_error(self, mail_server, smtp_server, exception):
|
2019-11-18 11:46:59 +01:00
|
|
|
values = {"state": "error"}
|
|
|
|
IrMailServer = self.env["ir.mail_server"]
|
|
|
|
if (
|
|
|
|
str(exception) == IrMailServer.NO_VALID_RECIPIENT
|
|
|
|
and not self.recipient_address
|
|
|
|
):
|
|
|
|
values.update(
|
|
|
|
{
|
|
|
|
"error_type": "no_recipient",
|
|
|
|
"error_description": "The partner doesn't have a defined email",
|
|
|
|
}
|
|
|
|
)
|
2019-10-17 03:28:42 +02:00
|
|
|
else:
|
2019-11-18 11:46:59 +01:00
|
|
|
values.update(
|
|
|
|
{
|
|
|
|
"error_smtp_server": tools.ustr(smtp_server),
|
|
|
|
"error_type": exception.__class__.__name__,
|
|
|
|
"error_description": tools.ustr(exception),
|
|
|
|
}
|
|
|
|
)
|
|
|
|
self.sudo()._partners_email_bounced_set("error")
|
2019-10-17 03:28:42 +02:00
|
|
|
self.sudo().write(values)
|
2016-06-14 17:22:17 +02:00
|
|
|
|
|
|
|
def tracking_img_add(self, email):
|
|
|
|
self.ensure_one()
|
|
|
|
tracking_url = self._get_mail_tracking_img()
|
|
|
|
if tracking_url:
|
2019-11-18 11:46:59 +01:00
|
|
|
content = email.get("body", "")
|
2017-10-10 11:30:20 +02:00
|
|
|
content = re.sub(
|
2019-11-18 11:46:59 +01:00
|
|
|
r'<img[^>]*data-odoo-tracking-email=["\'][0-9]*["\'][^>]*>', "", content
|
|
|
|
)
|
2016-06-14 17:22:17 +02:00
|
|
|
body = tools.append_content_to_html(
|
2019-11-18 11:46:59 +01:00
|
|
|
content, tracking_url, plaintext=False, container_tag="div"
|
|
|
|
)
|
|
|
|
email["body"] = body
|
2016-06-14 17:22:17 +02:00
|
|
|
return email
|
|
|
|
|
|
|
|
def _message_partners_check(self, message, message_id):
|
2016-11-22 11:30:55 +01:00
|
|
|
if not self.mail_message_id.exists(): # pragma: no cover
|
|
|
|
return True
|
2016-06-14 17:22:17 +02:00
|
|
|
mail_message = self.mail_message_id
|
2019-11-18 11:34:02 +01:00
|
|
|
partners = mail_message.notified_partner_ids | mail_message.partner_ids
|
|
|
|
if self.partner_id and self.partner_id not in partners:
|
2016-06-14 17:22:17 +02:00
|
|
|
# If mail_message haven't tracking partner, then
|
2016-09-09 18:33:21 +02:00
|
|
|
# add it in order to see his tracking status in chatter
|
2016-06-14 17:22:17 +02:00
|
|
|
if mail_message.subtype_id:
|
2019-11-18 11:34:02 +01:00
|
|
|
mail_message.sudo().write(
|
|
|
|
{"notified_partner_ids": [(4, self.partner_id.id)]}
|
|
|
|
)
|
2016-06-14 17:22:17 +02:00
|
|
|
else:
|
2019-11-18 11:46:59 +01:00
|
|
|
mail_message.sudo().write({"partner_ids": [(4, self.partner_id.id)]})
|
2016-06-14 17:22:17 +02:00
|
|
|
return True
|
|
|
|
|
2019-11-18 11:46:59 +01:00
|
|
|
def _tracking_sent_prepare(self, mail_server, smtp_server, message, message_id):
|
2016-06-14 17:22:17 +02:00
|
|
|
self.ensure_one()
|
|
|
|
ts = time.time()
|
|
|
|
dt = datetime.utcfromtimestamp(ts)
|
|
|
|
self._message_partners_check(message, message_id)
|
2019-11-18 11:46:59 +01:00
|
|
|
self.sudo().write({"state": "sent"})
|
2016-06-14 17:22:17 +02:00
|
|
|
return {
|
2019-11-18 11:46:59 +01:00
|
|
|
"recipient": message["To"],
|
|
|
|
"timestamp": "%.6f" % ts,
|
|
|
|
"time": fields.Datetime.to_string(dt),
|
|
|
|
"tracking_email_id": self.id,
|
|
|
|
"event_type": "sent",
|
|
|
|
"smtp_server": smtp_server,
|
2016-06-14 17:22:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
def _event_prepare(self, event_type, metadata):
|
|
|
|
self.ensure_one()
|
2019-11-18 11:46:59 +01:00
|
|
|
m_event = self.env["mail.tracking.event"]
|
|
|
|
method = getattr(m_event, "process_" + event_type, None)
|
|
|
|
if method and callable(method):
|
2016-06-14 17:22:17 +02:00
|
|
|
return method(self, metadata)
|
|
|
|
else: # pragma: no cover
|
2019-11-18 11:46:59 +01:00
|
|
|
_logger.info("Unknown event type: %s" % event_type)
|
2016-06-14 17:22:17 +02:00
|
|
|
return False
|
|
|
|
|
2016-09-09 13:29:58 +02:00
|
|
|
def _concurrent_events(self, event_type, metadata):
|
2019-11-18 11:46:59 +01:00
|
|
|
m_event = self.env["mail.tracking.event"]
|
2016-09-09 13:29:58 +02:00
|
|
|
self.ensure_one()
|
|
|
|
concurrent_event_ids = False
|
2019-11-18 11:46:59 +01:00
|
|
|
if event_type in {"open", "click"}:
|
|
|
|
ts = metadata.get("timestamp", time.time())
|
|
|
|
delta = EVENT_OPEN_DELTA if event_type == "open" else EVENT_CLICK_DELTA
|
2016-09-09 13:29:58 +02:00
|
|
|
domain = [
|
2019-11-18 11:46:59 +01:00
|
|
|
("timestamp", ">=", ts - delta),
|
|
|
|
("timestamp", "<=", ts + delta),
|
|
|
|
("tracking_email_id", "=", self.id),
|
|
|
|
("event_type", "=", event_type),
|
2016-09-09 13:29:58 +02:00
|
|
|
]
|
2019-11-18 11:46:59 +01:00
|
|
|
if event_type == "click":
|
|
|
|
domain.append(("url", "=", metadata.get("url", False)))
|
2016-09-09 13:29:58 +02:00
|
|
|
concurrent_event_ids = m_event.search(domain)
|
|
|
|
return concurrent_event_ids
|
|
|
|
|
2016-06-14 17:22:17 +02:00
|
|
|
def event_create(self, event_type, metadata):
|
2019-11-18 11:46:59 +01:00
|
|
|
event_ids = self.env["mail.tracking.event"]
|
2016-06-14 17:22:17 +02:00
|
|
|
for tracking_email in self:
|
2016-09-09 13:29:58 +02:00
|
|
|
other_ids = tracking_email._concurrent_events(event_type, metadata)
|
|
|
|
if not other_ids:
|
|
|
|
vals = tracking_email._event_prepare(event_type, metadata)
|
|
|
|
if vals:
|
2016-11-25 19:03:11 +01:00
|
|
|
events = event_ids.sudo().create(vals)
|
2019-11-18 11:46:59 +01:00
|
|
|
if event_type in {"hard_bounce", "spam", "reject"}:
|
2016-11-25 19:03:11 +01:00
|
|
|
for event in events:
|
|
|
|
self.sudo()._partners_email_bounced_set(
|
2019-11-18 11:46:59 +01:00
|
|
|
event_type, event=event
|
|
|
|
)
|
2016-11-25 19:03:11 +01:00
|
|
|
event_ids += events
|
2016-09-09 13:29:58 +02:00
|
|
|
else:
|
|
|
|
_logger.debug("Concurrent event '%s' discarded", event_type)
|
2016-06-14 17:22:17 +02:00
|
|
|
return event_ids
|
|
|
|
|
|
|
|
@api.model
|
|
|
|
def event_process(self, request, post, metadata, event_type=None):
|
|
|
|
# Generic event process hook, inherit it and
|
|
|
|
# - return 'OK' if processed
|
|
|
|
# - return 'NONE' if this request is not for you
|
|
|
|
# - return 'ERROR' if any error
|
2019-11-18 11:46:59 +01:00
|
|
|
return "NONE" # pragma: no cover
|