Skip to content

Commit

Permalink
Merge PR #1265 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Dec 12, 2023
2 parents 2d37f59 + e729495 commit 444ad4a
Show file tree
Hide file tree
Showing 25 changed files with 1,522 additions and 0 deletions.
96 changes: 96 additions & 0 deletions mass_mailing_unique/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
===============================
Unique records for mass mailing
===============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f5940baf01ac9e97a9657f3d32ee223ed89599e4ddb03a316dc72aa39b7d3d91
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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%2Fsocial-lightgray.png?logo=github
:target: https://github.com/OCA/social/tree/16.0/mass_mailing_unique
:alt: OCA/social
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/social-16-0/social-16-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/social&target_branch=16.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 <https://github.com/OCA/social/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 <https://github.com/OCA/social/issues/new?body=module:%20mass_mailing_unique%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~

* Tecnativa

Contributors
~~~~~~~~~~~~

* `Tecnativa <https://www.tecnativa.com>`_:

* Jairo Llopis
* Vicent Cubells
* Pedro M. Baeza
* Ernesto Tejeda
* `Camptocamp <https://www.camptocamp.com>`_

* Iván Todorovich <[email protected]>

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/social <https://github.com/OCA/social/tree/16.0/mass_mailing_unique>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
6 changes: 6 additions & 0 deletions mass_mailing_unique/__init__.py
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions mass_mailing_unique/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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": "16.0.1.0.0",
"category": "Marketing",
"website": "https://github.com/OCA/social",
"author": "Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3",
"depends": ["mass_mailing"],
"pre_init_hook": "pre_init_hook",
}
48 changes: 48 additions & 0 deletions mass_mailing_unique/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# 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 import _
from odoo.exceptions import ValidationError


def pre_init_hook(cr):
"""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
cr.execute(
"""
SELECT email_normalized, COUNT(id) as count
FROM mailing_contact
GROUP BY email_normalized
HAVING COUNT(id) > 1
"""
)
for result in cr.fetchall():
errors.append(
"There are {1} mailing contacts with the same email: {0}".format(*result)
)
# Search for duplicates in list's name
cr.execute(
"""
SELECT name, COUNT(id) as count
FROM mailing_list
GROUP BY name
HAVING COUNT(id) > 1
"""
)
for result in 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(
_("Unable to install module mass_mailing_unique:\n%s", "\n".join(errors))
)
83 changes: 83 additions & 0 deletions mass_mailing_unique/i18n/ca.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mass_mailing_unique
#
# Translators:
# Carles Antoli <[email protected]>, 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 <[email protected]>, 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.fields,field_description:mass_mailing_unique.field_mailing_contact__display_name
#: model:ir.model.fields,field_description:mass_mailing_unique.field_mailing_list__display_name
msgid "Display Name"
msgstr ""

#. module: mass_mailing_unique
#: model:ir.model.fields,field_description:mass_mailing_unique.field_mailing_contact__id
#: model:ir.model.fields,field_description:mass_mailing_unique.field_mailing_list__id
msgid "ID"
msgstr ""

#. module: mass_mailing_unique
#: model:ir.model.fields,field_description:mass_mailing_unique.field_mailing_contact____last_update
#: model:ir.model.fields,field_description:mass_mailing_unique.field_mailing_list____last_update
msgid "Last Modified on"
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 "Llista d'enviament"

#. module: mass_mailing_unique
#: model:ir.model.constraint,message:mass_mailing_unique.constraint_mailing_contact_unique_email
msgid "There's already a contact with this email address"
msgstr ""

#. module: mass_mailing_unique
#: 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}."
82 changes: 82 additions & 0 deletions mass_mailing_unique/i18n/de.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mass_mailing_unique
#
# Translators:
# Rudolf Schnapka <[email protected]>, 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 <[email protected]>, 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.fields,field_description:mass_mailing_unique.field_mailing_contact__display_name
#: model:ir.model.fields,field_description:mass_mailing_unique.field_mailing_list__display_name
msgid "Display Name"
msgstr ""

#. module: mass_mailing_unique
#: model:ir.model.fields,field_description:mass_mailing_unique.field_mailing_contact__id
#: model:ir.model.fields,field_description:mass_mailing_unique.field_mailing_list__id
msgid "ID"
msgstr ""

#. module: mass_mailing_unique
#: model:ir.model.fields,field_description:mass_mailing_unique.field_mailing_contact____last_update
#: model:ir.model.fields,field_description:mass_mailing_unique.field_mailing_list____last_update
msgid "Last Modified on"
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 "Mailingliste"

#. module: mass_mailing_unique
#: model:ir.model.constraint,message:mass_mailing_unique.constraint_mailing_contact_unique_email
msgid "There's already a contact with this email address"
msgstr ""

#. module: mass_mailing_unique
#: 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}."
Loading

0 comments on commit 444ad4a

Please sign in to comment.