diff --git a/mass_mailing_unique/README.rst b/mass_mailing_unique/README.rst new file mode 100644 index 0000000..fa396e3 --- /dev/null +++ b/mass_mailing_unique/README.rst @@ -0,0 +1,97 @@ +=============================== +Unique records for mass mailing +=============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:6c5fd9d116a02db48f1af0912637513299c74afcbb9f6d256a89330ba9f9cfbe + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmass--mailing-lightgray.png?logo=github + :target: https://github.com/OCA/mass-mailing/tree/18.0/mass_mailing_unique + :alt: OCA/mass-mailing +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/mass-mailing-18-0/mass-mailing-18-0-mass_mailing_unique + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/mass-mailing&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionality of mass mailing lists to disable +duplicate entries in list names and contact emails. + +This way you will avoid conflicts when importing contacts to a list that +has a duplicated name. + +**Table of contents** + +.. contents:: + :local: + +Installation +============ + +Before installing this module, you need to: + +- Remove all duplicated list names. +- Remove all duplicated emails in mailing contacts. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Tecnativa + +Contributors +------------ + +- `Tecnativa `__: + + - Jairo Llopis + - Vicent Cubells + - Pedro M. Baeza + - Ernesto Tejeda + +- `Camptocamp `__ + + - Iván Todorovich + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/mass-mailing `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mass_mailing_unique/__init__.py b/mass_mailing_unique/__init__.py new file mode 100644 index 0000000..50800f2 --- /dev/null +++ b/mass_mailing_unique/__init__.py @@ -0,0 +1,6 @@ +# Copyright 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis +# Copyright 2016 Tecnativa - Vicent Cubells +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models +from .hooks import pre_init_hook diff --git a/mass_mailing_unique/__manifest__.py b/mass_mailing_unique/__manifest__.py new file mode 100644 index 0000000..737a618 --- /dev/null +++ b/mass_mailing_unique/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis +# Copyright 2016 Tecnativa - Vicent Cubells +# Copyright 2018 Tecnativa - Ernesto Tejeda +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Unique records for mass mailing", + "summary": "Avoids duplicate mailing lists and contacts", + "version": "18.0.1.0.0", + "category": "Marketing", + "website": "https://github.com/OCA/mass-mailing", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": ["mass_mailing"], + "pre_init_hook": "pre_init_hook", +} diff --git a/mass_mailing_unique/hooks.py b/mass_mailing_unique/hooks.py new file mode 100644 index 0000000..b052db1 --- /dev/null +++ b/mass_mailing_unique/hooks.py @@ -0,0 +1,49 @@ +# Copyright 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis +# Copyright 2016 Tecnativa - Vicent Cubells +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.exceptions import ValidationError + + +def pre_init_hook(env): + """Make sure there are no duplicates before installing the module. + + If you define an unique key in Odoo that cannot be applied, Odoo will log a + warning and install the module without that constraint. Since this module + is useless without those constraints, we check here if all will work before + installing, and provide a user-friendly message in case of failure. + """ + errors = list() + # Search for duplicates in emails + env.cr.execute( + """ + SELECT email_normalized, COUNT(id) as count + FROM mailing_contact + GROUP BY email_normalized + HAVING COUNT(id) > 1 + """ + ) + for result in env.cr.fetchall(): + errors.append( + "There are {1} mailing contacts with the same email: {0}".format(*result) + ) + # Search for duplicates in list's name + env.cr.execute( + """ + SELECT name, COUNT(id) as count + FROM mailing_list + GROUP BY name + HAVING COUNT(id) > 1 + """ + ) + for result in env.cr.fetchall(): + errors.append( + "There are {1} mailing lists with the same name: {0}.".format(*result) + ) + # Abort if duplicates are found + if errors: + raise ValidationError( + env._( + "Unable to install module mass_mailing_unique:\n%s", "\n".join(errors) + ) + ) diff --git a/mass_mailing_unique/i18n/ca.po b/mass_mailing_unique/i18n/ca.po new file mode 100644 index 0000000..ad23475 --- /dev/null +++ b/mass_mailing_unique/i18n/ca.po @@ -0,0 +1,68 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mass_mailing_unique +# +# Translators: +# Carles Antoli , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-01-07 07:32+0000\n" +"PO-Revision-Date: 2017-01-07 07:32+0000\n" +"Last-Translator: Carles Antoli , 2017\n" +"Language-Team: Catalan (https://www.transifex.com/oca/teams/23907/ca/)\n" +"Language: ca\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: mass_mailing_unique +#: model:ir.model.constraint,message:mass_mailing_unique.constraint_mailing_list_unique_name +msgid "Cannot have more than one lists with the same name." +msgstr "No es pot tenir més d'una llista amb el mateix nom." + +#. module: mass_mailing_unique +#: model:ir.model,name:mass_mailing_unique.model_mailing_contact +msgid "Mailing Contact" +msgstr "" + +#. module: mass_mailing_unique +#: model:ir.model,name:mass_mailing_unique.model_mailing_list +msgid "Mailing List" +msgstr "Llista d'enviament" + +#. module: mass_mailing_unique +#: model:ir.model.constraint,message:mass_mailing_unique.constraint_mailing_contact_unique_email +msgid "" +"There's already an existing mailing contact with this email address. \n" +"Delete that existing record or change its email field value." +msgstr "" + +#. module: mass_mailing_unique +#. odoo-python +#: code:addons/mass_mailing_unique/hooks.py:0 +#, python-format +msgid "" +"Unable to install module mass_mailing_unique:\n" +"%s" +msgstr "" + +#~ msgid "Mass Mailing Contact" +#~ msgstr "Contactes del correu massiu" + +#, fuzzy +#~ msgid "Cannot have the same email (%s) morethan once in the same list." +#~ msgstr "" +#~ "No es pot tenir el mateix correu electrònic més d'una vegada en la " +#~ "mateixa llista." + +#~ msgid "Fix this before installing:" +#~ msgstr "Solucionar això abans d'instal·lar:" + +#~ msgid "There are {1} lists with name {0}." +#~ msgstr "Hi ha {1} llistes amb el nom {0}." + +#~ msgid "{0} appears {2} times in list {1}." +#~ msgstr "{0} apareix {2} vegades en la llista {1}." diff --git a/mass_mailing_unique/i18n/de.po b/mass_mailing_unique/i18n/de.po new file mode 100644 index 0000000..f382914 --- /dev/null +++ b/mass_mailing_unique/i18n/de.po @@ -0,0 +1,67 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mass_mailing_unique +# +# Translators: +# Rudolf Schnapka , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-03-28 08:19+0000\n" +"PO-Revision-Date: 2017-03-28 08:19+0000\n" +"Last-Translator: Rudolf Schnapka , 2017\n" +"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: mass_mailing_unique +#: model:ir.model.constraint,message:mass_mailing_unique.constraint_mailing_list_unique_name +msgid "Cannot have more than one lists with the same name." +msgstr "Sie dürfen nicht mehrere Listen gleich Namens führen." + +#. module: mass_mailing_unique +#: model:ir.model,name:mass_mailing_unique.model_mailing_contact +msgid "Mailing Contact" +msgstr "" + +#. module: mass_mailing_unique +#: model:ir.model,name:mass_mailing_unique.model_mailing_list +msgid "Mailing List" +msgstr "Mailingliste" + +#. module: mass_mailing_unique +#: model:ir.model.constraint,message:mass_mailing_unique.constraint_mailing_contact_unique_email +msgid "" +"There's already an existing mailing contact with this email address. \n" +"Delete that existing record or change its email field value." +msgstr "" + +#. module: mass_mailing_unique +#. odoo-python +#: code:addons/mass_mailing_unique/hooks.py:0 +#, python-format +msgid "" +"Unable to install module mass_mailing_unique:\n" +"%s" +msgstr "" + +#~ msgid "Mass Mailing Contact" +#~ msgstr "Massenmail-Kontakt" + +#, fuzzy +#~ msgid "Cannot have the same email (%s) morethan once in the same list." +#~ msgstr "" +#~ "Die gleiche Email-Anschrift darf nicht mehrmals in einer Liste vorkommen." + +#~ msgid "Fix this before installing:" +#~ msgstr "Beheben Sie dies vor der Installation:" + +#~ msgid "There are {1} lists with name {0}." +#~ msgstr "Es gibt {1} Liste mit Name {0}." + +#~ msgid "{0} appears {2} times in list {1}." +#~ msgstr "{0} erscheint {2} mal in der Liste {1}." diff --git a/mass_mailing_unique/i18n/es.po b/mass_mailing_unique/i18n/es.po new file mode 100644 index 0000000..968981e --- /dev/null +++ b/mass_mailing_unique/i18n/es.po @@ -0,0 +1,81 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mass_mailing_unique +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-01-04 03:40+0000\n" +"PO-Revision-Date: 2023-12-12 16:22+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: mass_mailing_unique +#: model:ir.model.constraint,message:mass_mailing_unique.constraint_mailing_list_unique_name +msgid "Cannot have more than one lists with the same name." +msgstr "No se puede tener más de una lista con el mismo nombre." + +#. module: mass_mailing_unique +#: model:ir.model,name:mass_mailing_unique.model_mailing_contact +msgid "Mailing Contact" +msgstr "Contacto por Correo" + +#. module: mass_mailing_unique +#: model:ir.model,name:mass_mailing_unique.model_mailing_list +msgid "Mailing List" +msgstr "Lista de correo" + +#. module: mass_mailing_unique +#: model:ir.model.constraint,message:mass_mailing_unique.constraint_mailing_contact_unique_email +msgid "" +"There's already an existing mailing contact with this email address. \n" +"Delete that existing record or change its email field value." +msgstr "" + +#. module: mass_mailing_unique +#. odoo-python +#: code:addons/mass_mailing_unique/hooks.py:0 +#, python-format +msgid "" +"Unable to install module mass_mailing_unique:\n" +"%s" +msgstr "" +"No se ha podido instalar el módulo mass_mailing_unique:\n" +"%s" + +#~ msgid "Display Name" +#~ msgstr "Mostrar Nombre" + +#~ msgid "ID" +#~ msgstr "ID" + +#~ msgid "Last Modified on" +#~ msgstr "Última Modificación el" + +#~ msgid "There's already a contact with this email address" +#~ msgstr "Ya hay un contacto con esta dirección de correo electrónico" + +#~ msgid "Mass Mailing Contact" +#~ msgstr "Contacto de envío masivo" + +#, fuzzy +#~ msgid "Cannot have the same email (%s) morethan once in the same list." +#~ msgstr "No se puede tener el mismo email varias veces en la misma lista." + +#~ msgid "Fix this before installing:" +#~ msgstr "Arregle esto antes de instalar:" + +#~ msgid "There are {1} lists with name {0}." +#~ msgstr "Hay {1} listas con el nombre {0}." + +#~ msgid "{0} appears {2} times in list {1}." +#~ msgstr "{0} aparece {2} veces en la lista {1}." diff --git a/mass_mailing_unique/i18n/fr.po b/mass_mailing_unique/i18n/fr.po new file mode 100644 index 0000000..84ea8d4 --- /dev/null +++ b/mass_mailing_unique/i18n/fr.po @@ -0,0 +1,85 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mass_mailing_unique +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-01-04 03:40+0000\n" +"PO-Revision-Date: 2021-03-04 13:45+0000\n" +"Last-Translator: Rémi \n" +"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: mass_mailing_unique +#: model:ir.model.constraint,message:mass_mailing_unique.constraint_mailing_list_unique_name +msgid "Cannot have more than one lists with the same name." +msgstr "Impossible d'avoir plus d'une liste avec le même nom." + +#. module: mass_mailing_unique +#: model:ir.model,name:mass_mailing_unique.model_mailing_contact +msgid "Mailing Contact" +msgstr "" + +#. module: mass_mailing_unique +#: model:ir.model,name:mass_mailing_unique.model_mailing_list +msgid "Mailing List" +msgstr "Liste de diffusion" + +#. module: mass_mailing_unique +#: model:ir.model.constraint,message:mass_mailing_unique.constraint_mailing_contact_unique_email +msgid "" +"There's already an existing mailing contact with this email address. \n" +"Delete that existing record or change its email field value." +msgstr "" + +#. module: mass_mailing_unique +#. odoo-python +#: code:addons/mass_mailing_unique/hooks.py:0 +#, python-format +msgid "" +"Unable to install module mass_mailing_unique:\n" +"%s" +msgstr "" + +#, python-format +#~ msgid "" +#~ "Email (%(contact_email)s) already in mailing list(s):\n" +#~ " %(lists)s\n" +#~ " Please use a different email address or " +#~ "remove (%(contact_email)s) from the mailing list(s) " +#~ "above." +#~ msgstr "" +#~ "Courriel (%(contact_email)s) déjà dans la(les) liste(s) de diffusion :\n" +#~ " %(lists)s\n" +#~ " Merci d'utiliser une adresse courriel différente ou " +#~ "supprimer (%(contact_email)s) de la (des) liste(s) de " +#~ "diffusion ci-dessus." + +#~ msgid "Mass Mailing Contact" +#~ msgstr "Contact de la liste de diffusion" + +#~ msgid "Mass Mailing Subscription Information" +#~ msgstr "Information d'Abonnement au Publipostage" + +#, fuzzy +#~ msgid "Cannot have the same email (%s) morethan once in the same list." +#~ msgstr "" +#~ "Impossible d'avoir le même courriel plus d'une fois dans la même liste" + +#~ msgid "Fix this before installing:" +#~ msgstr "Fixer avant l'installation:" + +#~ msgid "There are {1} lists with name {0}." +#~ msgstr "Il y'a {1} listes avec le nom {0}." + +#~ msgid "{0} appears {2} times in list {1}." +#~ msgstr "{0} Apparaît {2} fois dans la liste {1}." diff --git a/mass_mailing_unique/i18n/hr.po b/mass_mailing_unique/i18n/hr.po new file mode 100644 index 0000000..90826b3 --- /dev/null +++ b/mass_mailing_unique/i18n/hr.po @@ -0,0 +1,62 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mass_mailing_unique +# +# Translators: +# Bole , 2017 +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-12-01 02:19+0000\n" +"PO-Revision-Date: 2017-12-01 02:19+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n" +"Language: hr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && " +"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" + +#. module: mass_mailing_unique +#: model:ir.model.constraint,message:mass_mailing_unique.constraint_mailing_list_unique_name +msgid "Cannot have more than one lists with the same name." +msgstr "Nije moguće imati više od jedne liste sa istim nazivom." + +#. module: mass_mailing_unique +#: model:ir.model,name:mass_mailing_unique.model_mailing_contact +msgid "Mailing Contact" +msgstr "" + +#. module: mass_mailing_unique +#: model:ir.model,name:mass_mailing_unique.model_mailing_list +msgid "Mailing List" +msgstr "Mailing lista" + +#. module: mass_mailing_unique +#: model:ir.model.constraint,message:mass_mailing_unique.constraint_mailing_contact_unique_email +msgid "" +"There's already an existing mailing contact with this email address. \n" +"Delete that existing record or change its email field value." +msgstr "" + +#. module: mass_mailing_unique +#. odoo-python +#: code:addons/mass_mailing_unique/hooks.py:0 +#, python-format +msgid "" +"Unable to install module mass_mailing_unique:\n" +"%s" +msgstr "" + +#~ msgid "Mass Mailing Contact" +#~ msgstr "Kontakti za masovno slanje" + +#, fuzzy +#~ msgid "Cannot have the same email (%s) morethan once in the same list." +#~ msgstr "Email mora biti jedinstven u listi." + +#~ msgid "Fix this before installing:" +#~ msgstr "Ispravite sljedeće prije instalacije:" diff --git a/mass_mailing_unique/i18n/it.po b/mass_mailing_unique/i18n/it.po new file mode 100644 index 0000000..0f3200d --- /dev/null +++ b/mass_mailing_unique/i18n/it.po @@ -0,0 +1,102 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mass_mailing_unique +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-01-04 03:40+0000\n" +"PO-Revision-Date: 2025-05-24 13:53+0000\n" +"Last-Translator: mymage \n" +"Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 5.10.4\n" + +#. module: mass_mailing_unique +#: model:ir.model.constraint,message:mass_mailing_unique.constraint_mailing_list_unique_name +msgid "Cannot have more than one lists with the same name." +msgstr "Non è possibile avere più di una lista con lo stesso nome." + +#. module: mass_mailing_unique +#: model:ir.model,name:mass_mailing_unique.model_mailing_contact +msgid "Mailing Contact" +msgstr "Contatto spedizione" + +#. module: mass_mailing_unique +#: model:ir.model,name:mass_mailing_unique.model_mailing_list +msgid "Mailing List" +msgstr "Mailing list" + +#. module: mass_mailing_unique +#: model:ir.model.constraint,message:mass_mailing_unique.constraint_mailing_contact_unique_email +msgid "" +"There's already an existing mailing contact with this email address. \n" +"Delete that existing record or change its email field value." +msgstr "" +"Esiste già un contatto di posta con questo indirizzo e-mail. \n" +"Eliminare il record esistente o modificare il valore del campo email." + +#. module: mass_mailing_unique +#. odoo-python +#: code:addons/mass_mailing_unique/hooks.py:0 +#, python-format +msgid "" +"Unable to install module mass_mailing_unique:\n" +"%s" +msgstr "" +"Non è possibile installare il modlo mass_mailing_unique:\n" +"%s" + +#~ msgid "Display Name" +#~ msgstr "Nome visualizzato" + +#~ msgid "ID" +#~ msgstr "ID" + +#~ msgid "Last Modified on" +#~ msgstr "Ultima modifica il" + +#~ msgid "There's already a contact with this email address" +#~ msgstr "Esiste già un contatto con questo indirizzo e-mail" + +#, python-format +#~ msgid "" +#~ "Email (%(contact_email)s) already in mailing list(s):\n" +#~ " %(lists)s\n" +#~ " Please use a different email address or " +#~ "remove (%(contact_email)s) from the mailing list(s) " +#~ "above." +#~ msgstr "" +#~ "L'indirizzo (%(contact_email)s) è già nella mailing list:\n" +#~ " %(lists)s\n" +#~ " Utilizzare un indirizzo e-mail diverso o " +#~ "rimuovere (%(contact_email)s) dalle liste " +#~ "sopraelencate." + +#~ msgid "Mass Mailing Contact" +#~ msgstr "Contatto Mass Mailing" + +#~ msgid "Mass Mailing Subscription Information" +#~ msgstr "Informazione iscrizione mailing di massa" + +#, fuzzy +#~ msgid "Cannot have the same email (%s) morethan once in the same list." +#~ msgstr "" +#~ "Non è possibile inserire la stessa email più di una volta nella stessa " +#~ "lista." + +#~ msgid "Fix this before installing:" +#~ msgstr "Da risolvere prima dell'installazione:" + +#~ msgid "There are {1} lists with name {0}." +#~ msgstr "Ci sono {1} liste con il nome {0}." + +#~ msgid "{0} appears {2} times in list {1}." +#~ msgstr "{0} appare {2} volte nella lista {1}." diff --git a/mass_mailing_unique/i18n/mass_mailing_unique.pot b/mass_mailing_unique/i18n/mass_mailing_unique.pot new file mode 100644 index 0000000..be4121a --- /dev/null +++ b/mass_mailing_unique/i18n/mass_mailing_unique.pot @@ -0,0 +1,45 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mass_mailing_unique +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: mass_mailing_unique +#: model:ir.model.constraint,message:mass_mailing_unique.constraint_mailing_list_unique_name +msgid "Cannot have more than one lists with the same name." +msgstr "" + +#. module: mass_mailing_unique +#: model:ir.model,name:mass_mailing_unique.model_mailing_contact +msgid "Mailing Contact" +msgstr "" + +#. module: mass_mailing_unique +#: model:ir.model,name:mass_mailing_unique.model_mailing_list +msgid "Mailing List" +msgstr "" + +#. module: mass_mailing_unique +#: model:ir.model.constraint,message:mass_mailing_unique.constraint_mailing_contact_unique_email +msgid "" +"There's already an existing mailing contact with this email address. \n" +"Delete that existing record or change its email field value." +msgstr "" + +#. module: mass_mailing_unique +#. odoo-python +#: code:addons/mass_mailing_unique/hooks.py:0 +#, python-format +msgid "" +"Unable to install module mass_mailing_unique:\n" +"%s" +msgstr "" diff --git a/mass_mailing_unique/i18n/pt.po b/mass_mailing_unique/i18n/pt.po new file mode 100644 index 0000000..b8c9ef7 --- /dev/null +++ b/mass_mailing_unique/i18n/pt.po @@ -0,0 +1,53 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mass_mailing_unique +# +# Translators: +# Pedro Castro Silva , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-12-02 13:18+0000\n" +"PO-Revision-Date: 2017-12-02 13:18+0000\n" +"Last-Translator: Pedro Castro Silva , 2017\n" +"Language-Team: Portuguese (https://www.transifex.com/oca/teams/23907/pt/)\n" +"Language: pt\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: mass_mailing_unique +#: model:ir.model.constraint,message:mass_mailing_unique.constraint_mailing_list_unique_name +msgid "Cannot have more than one lists with the same name." +msgstr "" + +#. module: mass_mailing_unique +#: model:ir.model,name:mass_mailing_unique.model_mailing_contact +msgid "Mailing Contact" +msgstr "" + +#. module: mass_mailing_unique +#: model:ir.model,name:mass_mailing_unique.model_mailing_list +msgid "Mailing List" +msgstr "" + +#. module: mass_mailing_unique +#: model:ir.model.constraint,message:mass_mailing_unique.constraint_mailing_contact_unique_email +msgid "" +"There's already an existing mailing contact with this email address. \n" +"Delete that existing record or change its email field value." +msgstr "" + +#. module: mass_mailing_unique +#. odoo-python +#: code:addons/mass_mailing_unique/hooks.py:0 +#, python-format +msgid "" +"Unable to install module mass_mailing_unique:\n" +"%s" +msgstr "" + +#~ msgid "Mass Mailing Contact" +#~ msgstr "Contacto do email em massa" diff --git a/mass_mailing_unique/i18n/sl.po b/mass_mailing_unique/i18n/sl.po new file mode 100644 index 0000000..4b195d4 --- /dev/null +++ b/mass_mailing_unique/i18n/sl.po @@ -0,0 +1,67 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mass_mailing_unique +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-01-04 03:40+0000\n" +"PO-Revision-Date: 2017-01-04 03:40+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" +"Language: sl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || " +"n%100==4 ? 2 : 3);\n" + +#. module: mass_mailing_unique +#: model:ir.model.constraint,message:mass_mailing_unique.constraint_mailing_list_unique_name +msgid "Cannot have more than one lists with the same name." +msgstr "Imate lahko le en seznam z istim imenom." + +#. module: mass_mailing_unique +#: model:ir.model,name:mass_mailing_unique.model_mailing_contact +msgid "Mailing Contact" +msgstr "" + +#. module: mass_mailing_unique +#: model:ir.model,name:mass_mailing_unique.model_mailing_list +msgid "Mailing List" +msgstr "Poštni seznam" + +#. module: mass_mailing_unique +#: model:ir.model.constraint,message:mass_mailing_unique.constraint_mailing_contact_unique_email +msgid "" +"There's already an existing mailing contact with this email address. \n" +"Delete that existing record or change its email field value." +msgstr "" + +#. module: mass_mailing_unique +#. odoo-python +#: code:addons/mass_mailing_unique/hooks.py:0 +#, python-format +msgid "" +"Unable to install module mass_mailing_unique:\n" +"%s" +msgstr "" + +#~ msgid "Mass Mailing Contact" +#~ msgstr "Stik masovne pošte" + +#, fuzzy +#~ msgid "Cannot have the same email (%s) morethan once in the same list." +#~ msgstr "Isti e-poštni naslov imate lahko le enkrat v istem seznamu." + +#~ msgid "Fix this before installing:" +#~ msgstr "Popravite pred namestitvijo:" + +#~ msgid "There are {1} lists with name {0}." +#~ msgstr "{1} seznamov z imenom {0}." + +#~ msgid "{0} appears {2} times in list {1}." +#~ msgstr "{0} se pojavi {2} krat v seznamu {1}." diff --git a/mass_mailing_unique/models/__init__.py b/mass_mailing_unique/models/__init__.py new file mode 100644 index 0000000..805ade7 --- /dev/null +++ b/mass_mailing_unique/models/__init__.py @@ -0,0 +1,2 @@ +from . import mailing_contact +from . import mailing_list diff --git a/mass_mailing_unique/models/mailing_contact.py b/mass_mailing_unique/models/mailing_contact.py new file mode 100644 index 0000000..514f641 --- /dev/null +++ b/mass_mailing_unique/models/mailing_contact.py @@ -0,0 +1,21 @@ +# Copyright 2018 Tecnativa - Ernesto Tejeda +# Copyright 2021 Camptocamp - Iván Todorovich +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models + + +class MailingContact(models.Model): + _inherit = "mailing.contact" + + _sql_constraints = [ + ( + "unique_email", + "UNIQUE(email_normalized)", + ( + "There's already an existing mailing contact" + " with this email address. \n" + "Delete that existing record or change its email field value." + ), + ) + ] diff --git a/mass_mailing_unique/models/mailing_list.py b/mass_mailing_unique/models/mailing_list.py new file mode 100644 index 0000000..a2511e1 --- /dev/null +++ b/mass_mailing_unique/models/mailing_list.py @@ -0,0 +1,18 @@ +# Copyright 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis +# Copyright 2016 Tecnativa - Vicent Cubells +# Copyright 2021 Camptocamp - Iván Todorovich +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models + + +class MailingList(models.Model): + _inherit = "mailing.list" + + _sql_constraints = [ + ( + "unique_name", + "UNIQUE(name)", + "Cannot have more than one lists with the same name.", + ) + ] diff --git a/mass_mailing_unique/pyproject.toml b/mass_mailing_unique/pyproject.toml new file mode 100644 index 0000000..4231d0c --- /dev/null +++ b/mass_mailing_unique/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/mass_mailing_unique/readme/CONTRIBUTORS.md b/mass_mailing_unique/readme/CONTRIBUTORS.md new file mode 100644 index 0000000..696ca74 --- /dev/null +++ b/mass_mailing_unique/readme/CONTRIBUTORS.md @@ -0,0 +1,10 @@ +- [Tecnativa](https://www.tecnativa.com): + + - Jairo Llopis + - Vicent Cubells + - Pedro M. Baeza + - Ernesto Tejeda + +- [Camptocamp](https://www.camptocamp.com) + + > - Iván Todorovich \ diff --git a/mass_mailing_unique/readme/DESCRIPTION.md b/mass_mailing_unique/readme/DESCRIPTION.md new file mode 100644 index 0000000..1957076 --- /dev/null +++ b/mass_mailing_unique/readme/DESCRIPTION.md @@ -0,0 +1,5 @@ +This module extends the functionality of mass mailing lists to disable +duplicate entries in list names and contact emails. + +This way you will avoid conflicts when importing contacts to a list that +has a duplicated name. diff --git a/mass_mailing_unique/readme/INSTALL.md b/mass_mailing_unique/readme/INSTALL.md new file mode 100644 index 0000000..9162bcc --- /dev/null +++ b/mass_mailing_unique/readme/INSTALL.md @@ -0,0 +1,4 @@ +Before installing this module, you need to: + +- Remove all duplicated list names. +- Remove all duplicated emails in mailing contacts. diff --git a/mass_mailing_unique/static/description/icon.png b/mass_mailing_unique/static/description/icon.png new file mode 100644 index 0000000..3a0328b Binary files /dev/null and b/mass_mailing_unique/static/description/icon.png differ diff --git a/mass_mailing_unique/static/description/index.html b/mass_mailing_unique/static/description/index.html new file mode 100644 index 0000000..dc064e5 --- /dev/null +++ b/mass_mailing_unique/static/description/index.html @@ -0,0 +1,449 @@ + + + + + +Unique records for mass mailing + + + +
+

Unique records for mass mailing

+ + +

Beta License: AGPL-3 OCA/mass-mailing Translate me on Weblate Try me on Runboat

+

This module extends the functionality of mass mailing lists to disable +duplicate entries in list names and contact emails.

+

This way you will avoid conflicts when importing contacts to a list that +has a duplicated name.

+

Table of contents

+ +
+

Installation

+

Before installing this module, you need to:

+
    +
  • Remove all duplicated list names.
  • +
  • Remove all duplicated emails in mailing contacts.
  • +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/mass-mailing project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/mass_mailing_unique/tests/__init__.py b/mass_mailing_unique/tests/__init__.py new file mode 100644 index 0000000..8df8686 --- /dev/null +++ b/mass_mailing_unique/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import test_mass_mailing_unique diff --git a/mass_mailing_unique/tests/test_mass_mailing_unique.py b/mass_mailing_unique/tests/test_mass_mailing_unique.py new file mode 100644 index 0000000..ea65982 --- /dev/null +++ b/mass_mailing_unique/tests/test_mass_mailing_unique.py @@ -0,0 +1,109 @@ +# Copyright 2016 Tecnativa - Pedro M. Baeza +# Copyright 2021 Camptocamp - Iván Todorovich +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from psycopg2 import IntegrityError + +from odoo.exceptions import ValidationError +from odoo.tests import common +from odoo.tools import mute_logger + +from ..hooks import pre_init_hook + + +class TestMassMailingUnique(common.TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.mailing_list = cls.env.ref("mass_mailing.mailing_list_data") + cls.mailing_contact = cls.env["mailing.contact"].create( + { + "name": "John Doe", + "email": "john.doe@example.com", + "list_ids": [(6, 0, cls.mailing_list.ids)], + } + ) + + def test_init_hook_list_mailing_list(self): + # Disable temporarily the constraint + self.env.cr.execute( + """ + ALTER TABLE mailing_list + DROP CONSTRAINT mailing_list_unique_name + """ + ) + # Create another list with the same exact name + self.env["mailing.list"].create({"name": self.mailing_list.name}) + with self.assertRaises(ValidationError): + pre_init_hook(self.env) + + def test_init_hook_list_mailing_contact(self): + # Disable temporarily the constraint + self.env.cr.execute( + """ + ALTER TABLE mailing_contact + DROP CONSTRAINT mailing_contact_unique_email + """ + ) + # Create another list with the same exact name + self.env["mailing.contact"].create( + { + "name": f"{self.mailing_contact.name} (2)", + "email": self.mailing_contact.email, + } + ) + self.env["mailing.contact"].flush_model() + with self.assertRaises(ValidationError): + pre_init_hook(self.env) + + def test_mailing_contact_unique_email_exact(self): + """Create a contact with the same exact email""" + with mute_logger("odoo.sql_db"): + with self.assertRaisesRegex(IntegrityError, "mailing_contact_unique_email"): + self.env["mailing.contact"].create( + { + "name": "John Doe (2)", + "email": "john.doe@example.com", + } + ) + self.env["mailing.contact"].flush_model() + + def test_mailing_contact_unique_email_same(self): + """Create a contact with the same email (not exact though)""" + with mute_logger("odoo.sql_db"): + with self.assertRaisesRegex(IntegrityError, "mailing_contact_unique_email"): + self.env["mailing.contact"].create( + { + "name": "John Doe (2)", + "email": " John.DOE@example.com", + } + ) + self.env["mailing.contact"].flush_model() + + def test_mailing_contact_unique_email_ok(self): + """Create a contact with another email""" + self.env["mailing.contact"].create( + { + "name": "Jane Doe", + "email": "jane.doe@example.com", + } + ) + + def test_mailing_list_unique_name_duplicated(self): + """Create a mailing list with the same name""" + with mute_logger("odoo.sql_db"): + with self.assertRaisesRegex(IntegrityError, "mailing_list_unique_name"): + self.env["mailing.list"].create( + { + "name": self.mailing_list.name, + } + ) + self.env["mailing.list"].flush_model() + + def test_mailing_list_unique_name_ok(self): + """Create a mailing list with another name""" + self.env["mailing.list"].create( + { + "name": "Another mailing list", + } + )