summaryrefslogtreecommitdiff
path: root/addons/mass_mailing/models/mail_thread.py
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2019-07-17 09:26:42 +0000
committerThibault Delavallée <tde@odoo.com>2019-07-17 15:39:06 +0000
commit2896aad34e797b6ca65a8efe3c5d71f31500a9a2 (patch)
tree81f2298b04182860e84f2ca9815f313cc0c75ffc /addons/mass_mailing/models/mail_thread.py
parent20dfba6e11ac4553509c1a3516c6453b8f8023e7 (diff)
[REF] mass_mailing: rename mail.mail.statistics and reporting model
PURPOSE Mass mailing is currently a bit messy. As SMS will be added as a way to notify people in mass through SMS let us take this opportunity to somehow clean this application: organization, light code cleaning, model renaming. SPECIFICATIONS Rename mail.mail.statistics to mailing.trace and mail.statistics.report to mail.trace.report. Rationale : * mail.mail.statistics is linked to mail.mail model. Soon this model will hold data related to SMS sending. It makes sense to be broader in the naming; * mailing.trace is more inlined with marketing.trace model that is the marketing automation model using it in marketing automation (enterprise application); * mailing.trace is shorter to write; * mail.statistics.report model should sense to be updated at the same time; MIGRATION mail.mail.statistics model -> mailing.trace mail_mail_statistics table -> mailing_trace mail.statistics.report model -> mail.trace.report fields updated (w column change) * link.tracker.click: mail_stat_id -> mailing_trace_id fields updated (no column change) * mail.mail: statistics_ids -> mailing_trace_ids * mail.mass_mailing: statistics_ids -> mailing_trace_ids LINKS Task ID 2037906 Preparing task ID 1997464 (SMS addition in mass mailing) PR #34938
Diffstat (limited to 'addons/mass_mailing/models/mail_thread.py')
-rw-r--r--addons/mass_mailing/models/mail_thread.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/addons/mass_mailing/models/mail_thread.py b/addons/mass_mailing/models/mail_thread.py
index 5195672eead..28b02921801 100644
--- a/addons/mass_mailing/models/mail_thread.py
+++ b/addons/mass_mailing/models/mail_thread.py
@@ -13,12 +13,12 @@ BLACKLIST_MAX_BOUNCED_LIMIT = 5
class MailThread(models.AbstractModel):
- """ Update MailThread to add the support of bounce management in mass mailing statistics. """
+ """ Update MailThread to add the support of bounce management in mass mailing traces. """
_inherit = 'mail.thread'
@api.model
def message_route(self, message, message_dict, model=None, thread_id=None, custom_values=None):
- """ Override to udpate mass mailing statistics based on bounce emails """
+ """ Override to udpate mass mailing traces based on bounce emails """
bounce_alias = self.env['ir.config_parameter'].sudo().get_param("mail.bounce.alias")
email_to = decode_message_header(message, 'To')
email_to_localpart = (tools.email_split(email_to) or [''])[0].split('@', 1)[0].lower()
@@ -28,19 +28,19 @@ class MailThread(models.AbstractModel):
bounce_match = bounce_re.search(email_to)
if bounce_match:
bounced_mail_id = bounce_match.group(1)
- self.env['mail.mail.statistics'].set_bounced(mail_mail_ids=[bounced_mail_id])
+ self.env['mailing.trace'].set_bounced(mail_mail_ids=[bounced_mail_id])
return super(MailThread, self).message_route(message, message_dict, model, thread_id, custom_values)
@api.model
def message_route_process(self, message, message_dict, routes):
- """ Override to update the parent mail statistics. The parent is found
+ """ Override to update the parent mailing traces. The parent is found
by using the References header of the incoming message and looking for
- matching message_id in mail.mail.statistics. """
+ matching message_id in mailing.trace. """
if message.get('References') and routes:
message_ids = [x.strip() for x in decode_smtp_header(message['References']).split()]
- self.env['mail.mail.statistics'].set_opened(mail_message_ids=message_ids)
- self.env['mail.mail.statistics'].set_replied(mail_message_ids=message_ids)
+ self.env['mailing.trace'].set_opened(mail_message_ids=message_ids)
+ self.env['mailing.trace'].set_replied(mail_message_ids=message_ids)
return super(MailThread, self).message_route_process(message, message_dict, routes)
def message_post_with_template(self, template_id, **kwargs):
@@ -64,11 +64,11 @@ class MailThread(models.AbstractModel):
super(MailThread, self)._message_receive_bounce(email, partner, mail_id=None)
three_months_ago = fields.Datetime.to_string(datetime.datetime.now() - datetime.timedelta(weeks=13))
- stats = self.env['mail.mail.statistics'] \
+ traces = self.env['mailing.trace'] \
.search(['&', ('bounced', '>', three_months_ago), ('email', '=ilike', email)]) \
.mapped('bounced')
- if len(stats) >= BLACKLIST_MAX_BOUNCED_LIMIT:
- if max(stats) > min(stats) + datetime.timedelta(weeks=1):
+ if len(traces) >= BLACKLIST_MAX_BOUNCED_LIMIT:
+ if max(traces) > min(traces) + datetime.timedelta(weeks=1):
blacklist_rec = self.env['mail.blacklist'].sudo()._add(email)
blacklist_rec._message_log(
body='This email has been automatically blacklisted because of too much bounced.')