|
@ -183,12 +183,19 @@ class MailTrackingEmail(models.Model): |
|
|
'tracking_email_id': self.id, |
|
|
'tracking_email_id': self.id, |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
def _partners_email_bounced_set(self, reason): |
|
|
|
|
|
for tracking_email in self: |
|
|
|
|
|
|
|
|
@api.multi |
|
|
|
|
|
def _partners_email_bounced_set(self, reason, event=None): |
|
|
|
|
|
recipients = [] |
|
|
|
|
|
if event and event.recipient_address: |
|
|
|
|
|
recipients.append(event.recipient_address) |
|
|
|
|
|
else: |
|
|
|
|
|
recipients = list(filter(None, self.mapped('recipient_address'))) |
|
|
|
|
|
for recipient in recipients: |
|
|
self.env['res.partner'].search([ |
|
|
self.env['res.partner'].search([ |
|
|
('email', '=ilike', tracking_email.recipient_address) |
|
|
|
|
|
]).email_bounced_set(tracking_email, reason) |
|
|
|
|
|
|
|
|
('email', '=ilike', recipient) |
|
|
|
|
|
]).email_bounced_set(self, reason, event=event) |
|
|
|
|
|
|
|
|
|
|
|
@api.multi |
|
|
def smtp_error(self, mail_server, smtp_server, exception): |
|
|
def smtp_error(self, mail_server, smtp_server, exception): |
|
|
self.sudo().write({ |
|
|
self.sudo().write({ |
|
|
'error_smtp_server': tools.ustr(smtp_server), |
|
|
'error_smtp_server': tools.ustr(smtp_server), |
|
@ -199,6 +206,7 @@ class MailTrackingEmail(models.Model): |
|
|
self.sudo()._partners_email_bounced_set('error') |
|
|
self.sudo()._partners_email_bounced_set('error') |
|
|
return True |
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
@api.multi |
|
|
def tracking_img_add(self, email): |
|
|
def tracking_img_add(self, email): |
|
|
self.ensure_one() |
|
|
self.ensure_one() |
|
|
tracking_url = self._get_mail_tracking_img() |
|
|
tracking_url = self._get_mail_tracking_img() |
|
@ -226,6 +234,7 @@ class MailTrackingEmail(models.Model): |
|
|
}) |
|
|
}) |
|
|
return True |
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
@api.multi |
|
|
def _tracking_sent_prepare(self, mail_server, smtp_server, message, |
|
|
def _tracking_sent_prepare(self, mail_server, smtp_server, message, |
|
|
message_id): |
|
|
message_id): |
|
|
self.ensure_one() |
|
|
self.ensure_one() |
|
@ -271,6 +280,7 @@ class MailTrackingEmail(models.Model): |
|
|
concurrent_event_ids = m_event.search(domain) |
|
|
concurrent_event_ids = m_event.search(domain) |
|
|
return concurrent_event_ids |
|
|
return concurrent_event_ids |
|
|
|
|
|
|
|
|
|
|
|
@api.multi |
|
|
def event_create(self, event_type, metadata): |
|
|
def event_create(self, event_type, metadata): |
|
|
event_ids = self.env['mail.tracking.event'] |
|
|
event_ids = self.env['mail.tracking.event'] |
|
|
for tracking_email in self: |
|
|
for tracking_email in self: |
|
@ -278,11 +288,14 @@ class MailTrackingEmail(models.Model): |
|
|
if not other_ids: |
|
|
if not other_ids: |
|
|
vals = tracking_email._event_prepare(event_type, metadata) |
|
|
vals = tracking_email._event_prepare(event_type, metadata) |
|
|
if vals: |
|
|
if vals: |
|
|
event_ids += event_ids.sudo().create(vals) |
|
|
|
|
|
|
|
|
events = event_ids.sudo().create(vals) |
|
|
|
|
|
if event_type in {'hard_bounce', 'spam', 'reject'}: |
|
|
|
|
|
for event in events: |
|
|
|
|
|
self.sudo()._partners_email_bounced_set( |
|
|
|
|
|
event_type, event=event) |
|
|
|
|
|
event_ids += events |
|
|
else: |
|
|
else: |
|
|
_logger.debug("Concurrent event '%s' discarded", event_type) |
|
|
_logger.debug("Concurrent event '%s' discarded", event_type) |
|
|
if event_type in {'hard_bounce', 'spam', 'reject'}: |
|
|
|
|
|
self.sudo()._partners_email_bounced_set(event_type) |
|
|
|
|
|
return event_ids |
|
|
return event_ids |
|
|
|
|
|
|
|
|
@api.model |
|
|
@api.model |
|
|