ernesto
6 years ago
committed by
Holger Brunn
14 changed files with 114 additions and 40 deletions
-
10mass_mailing_unique/README.rst
-
1mass_mailing_unique/__init__.py
-
3mass_mailing_unique/__manifest__.py
-
10mass_mailing_unique/hooks.py
-
4mass_mailing_unique/models/__init__.py
-
22mass_mailing_unique/models/mail_mass_mailing_contact.py
-
12mass_mailing_unique/models/mail_mass_mailing_list.py
-
12mass_mailing_unique/models/mail_mass_mailing_list_contact_rel.py
-
20mass_mailing_unique/models/mass_mailing.py
-
5mass_mailing_unique/readme/DESCRIPTION.rst
-
6mass_mailing_unique/static/description/index.html
-
0mass_mailing_unique/static/img/error-duplicated-email.png
-
0mass_mailing_unique/static/img/error-duplicated-list.png
-
49mass_mailing_unique/tests/test_mass_mailing_unique.py
@ -0,0 +1,22 @@ |
|||
# Copyright 2018 Tecnativa - Ernesto Tejeda |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from odoo import _, api, models |
|||
from odoo.exceptions import ValidationError |
|||
|
|||
|
|||
class MailMassMailingContact(models.Model): |
|||
_inherit = 'mail.mass_mailing.contact' |
|||
|
|||
@api.constrains('email', 'list_ids') |
|||
def _check_email_list_ids(self): |
|||
for contact in self: |
|||
lists = contact.subscription_list_ids.mapped('list_id') |
|||
lists |= contact.list_ids |
|||
others = lists.mapped('contact_ids') - contact |
|||
|
|||
contact_email = contact.email.strip().lower() |
|||
other_emails = [e.strip().lower() for e in others.mapped('email')] |
|||
if contact_email in other_emails: |
|||
raise ValidationError(_("Cannot have the same email more " |
|||
"than once in the same list")) |
@ -0,0 +1,12 @@ |
|||
# Copyright 2018 Tecnativa - Ernesto Tejeda |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from odoo import api, models |
|||
|
|||
|
|||
class MailMassMailingList(models.Model): |
|||
_inherit = 'mail.mass_mailing.list' |
|||
|
|||
@api.constrains('contact_ids') |
|||
def _check_contact_ids_email(self): |
|||
self.mapped("contact_ids")._check_email_list_ids() |
@ -0,0 +1,12 @@ |
|||
# Copyright 2018 Tecnativa - Ernesto Tejeda |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from odoo import api, models |
|||
|
|||
|
|||
class MailMassMailingContactListRel(models.Model): |
|||
_inherit = 'mail.mass_mailing.list_contact_rel' |
|||
|
|||
@api.constrains('contact_id', 'list_id') |
|||
def _check_contact_id_partner_id_list_id(self): |
|||
self.mapped("contact_id")._check_email_list_ids() |
@ -1,6 +1,5 @@ |
|||
This module extends the functionality of mass mailing lists to disable |
|||
duplicate entries in list names and contact emails per list. |
|||
|
|||
This way you will avoid sending the same message more than once to the same |
|||
contact when selecting a mailing list, and you will avoid conflicts when |
|||
importing contacts to a list that has a duplicated name. |
|||
This way you will avoid conflicts when importing contacts to a list that has a |
|||
duplicated name. |
Before Width: 937 | Height: 289 | Size: 41 KiB After Width: 937 | Height: 289 | Size: 41 KiB |
Before Width: 961 | Height: 313 | Size: 36 KiB After Width: 961 | Height: 313 | Size: 36 KiB |
Write
Preview
Loading…
Cancel
Save
Reference in new issue