Bladeren bron

commit inicail

Deisy 8 jaren geleden
commit
53c7cb8951
16 gewijzigde bestanden met toevoegingen van 335 en 0 verwijderingen
  1. 67 0
      README.rst
  2. 6 0
      __init__.py
  3. BIN
      __init__.pyc
  4. 23 0
      __openerp__.py
  5. 43 0
      hooks.py
  6. BIN
      hooks.pyc
  7. 56 0
      i18n/es.po
  8. 57 0
      i18n/fr.po
  9. 57 0
      i18n/sl.po
  10. BIN
      images/error-duplicated-email.png
  11. BIN
      images/error-duplicated-list.png
  12. 5 0
      models/__init__.py
  13. BIN
      models/__init__.pyc
  14. 21 0
      models/mass_mailing.py
  15. BIN
      models/mass_mailing.pyc
  16. BIN
      static/description/icon.png

+ 67 - 0
README.rst

@@ -0,0 +1,67 @@
+.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
+   :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
+   :alt: License: AGPL-3
+
+===============================
+Unique records for mass mailing
+===============================
+
+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.
+
+Installation
+============
+
+Before installing this module, you need to:
+
+* Remove all duplicated list names.
+* Remove all duplicated emails in each list.
+
+Usage
+=====
+
+To use this module, you need to try to create a duplicated mailing list, or a
+duplicated email inside one. You will not can.
+
+.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
+   :alt: Try me on Runbot
+   :target: https://runbot.odoo-community.org/runbot/205/8.0
+
+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 smashing it by providing a detailed and welcomed `feedback
+<https://github.com/OCA/
+social/issues/new?body=module:%20
+mass_mailing_unique%0Aversion:%20
+8.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
+
+Credits
+=======
+
+Contributors
+------------
+
+* Jairo Llopis <yajo.sk8@gmail.com>
+
+Maintainer
+----------
+
+.. image:: https://odoo-community.org/logo.png
+   :alt: Odoo Community Association
+   :target: https://odoo-community.org
+
+This module is maintained by the OCA.
+
+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.
+
+To contribute to this module, please visit https://odoo-community.org.

+ 6 - 0
__init__.py

@@ -0,0 +1,6 @@
+# -*- coding: utf-8 -*-
+# © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from . import models
+from .hooks import pre_init_hook

BIN
__init__.pyc


+ 23 - 0
__openerp__.py

@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+# © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
+# 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": "8.0.1.0.0",
+    "category": "Marketing",
+    "website": "https://grupoesoc.es",
+    "author": "Grupo ESOC Ingeniería de Servicios, "
+              "Odoo Community Association (OCA)",
+    "license": "AGPL-3",
+    "application": False,
+    "installable": True,
+    "pre_init_hook": "pre_init_hook",
+    "images": [
+        "images/error-duplicated-email.png",
+        "images/error-duplicated-list.png",
+    ],
+    "depends": [
+        "mass_mailing",
+    ],
+}

+ 43 - 0
hooks.py

@@ -0,0 +1,43 @@
+# -*- coding: utf-8 -*-
+# © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from openerp import _
+from openerp.exceptions import ValidationError
+
+
+def pre_init_hook(cr):
+    """Make sure there are no duplicates before installing the module.
+
+    If you define a 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 c.email, l.name, COUNT(c.id)
+                  FROM
+                    mail_mass_mailing_contact AS c
+                    INNER JOIN mail_mass_mailing_list AS l ON c.list_id = l.id
+                  GROUP BY l.name, l.id, c.email
+                  HAVING COUNT(c.id) > 1""")
+    for result in cr.fetchall():
+        errors.append(
+            _("{0} appears {2} times in list {1}.").format(*result))
+
+    # Search for duplicates in list's name
+    cr.execute("""SELECT name, COUNT(id)
+                  FROM mail_mass_mailing_list
+                  GROUP BY name
+                  HAVING COUNT(id) > 1""")
+    for result in cr.fetchall():
+        errors.append(
+            _("There are {1} lists with name {0}.").format(*result))
+
+    # Abort if duplicates are found
+    if errors:
+        raise ValidationError(
+            _("Fix this before installing:") +
+            "".join("\n" + e for e in errors))

BIN
hooks.pyc


+ 56 - 0
i18n/es.po

@@ -0,0 +1,56 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# 	* mass_mailing_unique
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 8.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2016-01-29 12:37+0100\n"
+"PO-Revision-Date: 2016-01-29 12:38+0100\n"
+"Last-Translator: Jairo Llopis <j.llopis@grupoesoc.es>\n"
+"Language-Team: \n"
+"Language: es\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: \n"
+"X-Generator: Poedit 1.8.5\n"
+
+#. module: mass_mailing_unique
+#: sql_constraint:mail.mass_mailing.list:0
+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
+#: sql_constraint:mail.mass_mailing.contact:0
+msgid "Cannot have the same email more than once in the same list."
+msgstr "No se puede tener el mismo email varias veces en la misma lista."
+
+#. module: mass_mailing_unique
+#: code:addons/mass_mailing_unique/hooks.py:42
+#, python-format
+msgid "Fix this before installing:"
+msgstr "Arregle esto antes de instalar:"
+
+#. module: mass_mailing_unique
+#: model:ir.model,name:mass_mailing_unique.model_mail_mass_mailing_list
+msgid "Mailing List"
+msgstr "Lista de correo"
+
+#. module: mass_mailing_unique
+#: model:ir.model,name:mass_mailing_unique.model_mail_mass_mailing_contact
+msgid "Mass Mailing Contact"
+msgstr "Contacto de envío masivo"
+
+#. module: mass_mailing_unique
+#: code:addons/mass_mailing_unique/hooks.py:37
+#, python-format
+msgid "There are {1} lists with name {0}."
+msgstr "Hay {1} listas con el nombre {0}."
+
+#. module: mass_mailing_unique
+#: code:addons/mass_mailing_unique/hooks.py:28
+#, python-format
+msgid "{0} appears {2} times in list {1}."
+msgstr "{0} aparece {2} veces en la lista {1}."

+ 57 - 0
i18n/fr.po

@@ -0,0 +1,57 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * mass_mailing_unique
+# 
+# Translators:
+# Christophe CHAUVET <christophe.chauvet@gmail.com>, 2016
+msgid ""
+msgstr ""
+"Project-Id-Version: social (8.0)\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2016-06-30 01:07+0000\n"
+"PO-Revision-Date: 2016-06-22 09:25+0000\n"
+"Last-Translator: Christophe CHAUVET <christophe.chauvet@gmail.com>\n"
+"Language-Team: French (http://www.transifex.com/oca/OCA-social-8-0/language/fr/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Language: fr\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+
+#. module: mass_mailing_unique
+#: sql_constraint:mail.mass_mailing.list:0
+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
+#: sql_constraint:mail.mass_mailing.contact:0
+msgid "Cannot have the same email more than once in the same list."
+msgstr "Impossible d'avoir le même courriel plus d'une fois dans la même liste"
+
+#. module: mass_mailing_unique
+#: code:addons/mass_mailing_unique/hooks.py:42
+#, python-format
+msgid "Fix this before installing:"
+msgstr "Fixer avant l'installation:"
+
+#. module: mass_mailing_unique
+#: model:ir.model,name:mass_mailing_unique.model_mail_mass_mailing_list
+msgid "Mailing List"
+msgstr "Liste de diffusion"
+
+#. module: mass_mailing_unique
+#: model:ir.model,name:mass_mailing_unique.model_mail_mass_mailing_contact
+msgid "Mass Mailing Contact"
+msgstr "Contact de la liste de diffusion"
+
+#. module: mass_mailing_unique
+#: code:addons/mass_mailing_unique/hooks.py:37
+#, python-format
+msgid "There are {1} lists with name {0}."
+msgstr "Il y'a {1} listes avec le nom {0}."
+
+#. module: mass_mailing_unique
+#: code:addons/mass_mailing_unique/hooks.py:28
+#, python-format
+msgid "{0} appears {2} times in list {1}."
+msgstr "{0} Apparaît {2} fois dans la liste {1}."

+ 57 - 0
i18n/sl.po

@@ -0,0 +1,57 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * mass_mailing_unique
+# 
+# Translators:
+# Matjaž Mozetič <m.mozetic@matmoz.si>, 2016
+msgid ""
+msgstr ""
+"Project-Id-Version: social (8.0)\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2016-02-27 01:40+0000\n"
+"PO-Revision-Date: 2016-02-27 16:56+0000\n"
+"Last-Translator: Matjaž Mozetič <m.mozetic@matmoz.si>\n"
+"Language-Team: Slovenian (http://www.transifex.com/oca/OCA-social-8-0/language/sl/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Language: sl\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
+#: sql_constraint:mail.mass_mailing.list:0
+msgid "Cannot have more than one lists with the same name."
+msgstr "Imate lahko le en seznam z istim imenom."
+
+#. module: mass_mailing_unique
+#: sql_constraint:mail.mass_mailing.contact:0
+msgid "Cannot have the same email more than once in the same list."
+msgstr "Isti e-poštni naslov imate lahko le enkrat v istem seznamu."
+
+#. module: mass_mailing_unique
+#: code:addons/mass_mailing_unique/hooks.py:42
+#, python-format
+msgid "Fix this before installing:"
+msgstr "Popravite pred namestitvijo:"
+
+#. module: mass_mailing_unique
+#: model:ir.model,name:mass_mailing_unique.model_mail_mass_mailing_list
+msgid "Mailing List"
+msgstr "Poštni seznam"
+
+#. module: mass_mailing_unique
+#: model:ir.model,name:mass_mailing_unique.model_mail_mass_mailing_contact
+msgid "Mass Mailing Contact"
+msgstr "Stik masovne pošte"
+
+#. module: mass_mailing_unique
+#: code:addons/mass_mailing_unique/hooks.py:37
+#, python-format
+msgid "There are {1} lists with name {0}."
+msgstr "{1} seznamov z imenom {0}."
+
+#. module: mass_mailing_unique
+#: code:addons/mass_mailing_unique/hooks.py:28
+#, python-format
+msgid "{0} appears {2} times in list {1}."
+msgstr "{0} se pojavi {2} krat v seznamu {1}."

BIN
images/error-duplicated-email.png


BIN
images/error-duplicated-list.png


+ 5 - 0
models/__init__.py

@@ -0,0 +1,5 @@
+# -*- coding: utf-8 -*-
+# © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from . import mass_mailing

BIN
models/__init__.pyc


+ 21 - 0
models/mass_mailing.py

@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+# © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from openerp import models
+
+
+class MailMassMailingContact(models.Model):
+    _inherit = "mail.mass_mailing.contact"
+    _sql_constraints = [
+        ("unique_mail_per_list", "UNIQUE(list_id, email)",
+         "Cannot have the same email more than once in the same list.")
+    ]
+
+
+class MailMassMailingList(models.Model):
+    _inherit = "mail.mass_mailing.list"
+    _sql_constraints = [
+        ("unique_name", "UNIQUE(name)",
+         "Cannot have more than one lists with the same name.")
+    ]

BIN
models/mass_mailing.pyc


BIN
static/description/icon.png