[IMP] mass_mailing : include invalid emails into ignored state
If the email is invalid (incorrect pattern), the mailing status is set to canceled and will be flaged as ignored in the mail.mail.statistics
This commit is contained in:
@@ -3,9 +3,8 @@
|
||||
|
||||
import logging
|
||||
import re
|
||||
import datetime
|
||||
|
||||
from odoo import api, models, tools, fields
|
||||
from odoo import api, models, tools
|
||||
from odoo.tools import decode_smtp_header, decode_message_header
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -56,7 +56,6 @@ class MailMailStats(models.Model):
|
||||
state_update = fields.Datetime(compute="_compute_state", string='State Update',
|
||||
help='Last state update of the mail',
|
||||
store=True)
|
||||
recipient = fields.Char(compute="_compute_recipient")
|
||||
email = fields.Char(string="Recipient email address")
|
||||
|
||||
@api.depends('sent', 'opened', 'clicked', 'replied', 'bounced', 'exception', 'ignored')
|
||||
@@ -78,20 +77,6 @@ class MailMailStats(models.Model):
|
||||
else:
|
||||
stat.state = 'outgoing'
|
||||
|
||||
def _compute_recipient(self):
|
||||
for stat in self:
|
||||
if stat.model not in self.env:
|
||||
continue
|
||||
target = self.env[stat.model].browse(stat.res_id)
|
||||
if not target or not target.exists():
|
||||
continue
|
||||
email = ''
|
||||
for email_field in ('email', 'email_from'):
|
||||
if email_field in target and target[email_field]:
|
||||
email = ' <%s>' % target[email_field]
|
||||
break
|
||||
stat.recipient = '%s%s' % (target.display_name, email)
|
||||
|
||||
@api.model
|
||||
def create(self, values):
|
||||
if 'mail_mail_id' in values:
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<field name="model">mail.mail.statistics</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Mail Statistics" create="0">
|
||||
<field name="recipient"/>
|
||||
<field name="email"/>
|
||||
<field name="message_id"/>
|
||||
<field name="sent"/>
|
||||
<field name="exception"/>
|
||||
@@ -58,7 +58,7 @@
|
||||
<sheet>
|
||||
<group>
|
||||
<group>
|
||||
<field name="recipient"/>
|
||||
<field name="email"/>
|
||||
<field name="mass_mailing_id"/>
|
||||
<field name="mass_mailing_campaign_id" groups="mass_mailing.group_mass_mailing_campaign"/>
|
||||
</group>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import api, fields, models, tools
|
||||
from odoo.tools import email_re
|
||||
|
||||
|
||||
class MailComposeMessage(models.TransientModel):
|
||||
@@ -65,7 +66,8 @@ class MailComposeMessage(models.TransientModel):
|
||||
else:
|
||||
recips = tools.email_split(partners_email.get(res_id))
|
||||
mail_to = recips[0].lower() if recips else False
|
||||
if (opt_out_list and mail_to in opt_out_list) or (seen_list and mail_to in seen_list):
|
||||
if (opt_out_list and mail_to in opt_out_list) or (seen_list and mail_to in seen_list) \
|
||||
or (not mail_to or not email_re.findall(mail_to)):
|
||||
# prevent sending to blocked addresses that were included by mistake
|
||||
mail_values['state'] = 'cancel'
|
||||
elif seen_list is not None:
|
||||
|
||||
Reference in New Issue
Block a user