Browse Source

Link mail statistics to partner (#104)

[IMP] mass_mailing_partner: Link mail statistics to partner
pull/323/head
Antonio Espinosa 8 years ago
committed by Victor Martin
parent
commit
206801ae5e
  1. 15
      mass_mailing_partner/README.rst
  2. 22
      mass_mailing_partner/__init__.py
  3. 14
      mass_mailing_partner/__openerp__.py
  4. 37
      mass_mailing_partner/hooks.py
  5. 40
      mass_mailing_partner/i18n/es.po
  6. 28
      mass_mailing_partner/i18n/fr.po
  7. 83
      mass_mailing_partner/i18n/hr.po
  8. 28
      mass_mailing_partner/i18n/it.po
  9. 30
      mass_mailing_partner/i18n/sl.po
  10. 7
      mass_mailing_partner/models/__init__.py
  11. 37
      mass_mailing_partner/models/mail_mail_statistics.py
  12. 5
      mass_mailing_partner/models/mail_mass_mailing.py
  13. 8
      mass_mailing_partner/models/mail_mass_mailing_contact.py
  14. 25
      mass_mailing_partner/models/res_partner.py
  15. 6
      mass_mailing_partner/tests/__init__.py
  16. 5
      mass_mailing_partner/tests/base.py
  17. 28
      mass_mailing_partner/tests/test_mail_mail_statistics.py
  18. 20
      mass_mailing_partner/tests/test_mail_mass_mailing_contact.py
  19. 5
      mass_mailing_partner/tests/test_partner_mail_list_wizard.py
  20. 6
      mass_mailing_partner/tests/test_res_partner.py
  21. 46
      mass_mailing_partner/views/mail_mail_statistics_view.xml
  22. 7
      mass_mailing_partner/views/mail_mass_mailing_contact_view.xml
  23. 4
      mass_mailing_partner/views/mail_mass_mailing_view.xml
  24. 15
      mass_mailing_partner/views/res_partner_view.xml
  25. 5
      mass_mailing_partner/wizard/__init__.py
  26. 5
      mass_mailing_partner/wizard/partner_mail_list_wizard.py
  27. 4
      mass_mailing_partner/wizard/partner_mail_list_wizard.xml

15
mass_mailing_partner/README.rst

@ -14,14 +14,25 @@ Features
email, linking matched partner, or creating a new one if no match and the
maling list partner mandatory field is checked.
* Mailing contacts smart button in partner form.
* Mass mailing stats smart button in partner form.
* Filter and group by partner in mail statistics tree view
Configuration
=============
At first install, all existing mass mailing contacts are matched against
partners.
partners. And also mass mailing statistics are matched using model and res_id.
NOTE: When upgrading from version 1.0.0, no mass mailing statistics matching
are done, because it is done only when installing. You can execute 'partner_link'
method to all stats using odoo shell or any XML client:
.. code:: python
# odoo.py --addons-path=<addons_path_list> shell --config=<odoo_config_file> -d <database>
stats = self.env['mail.mail.statistics'].search([('model', '!=', False), ('res_id', '!=', False)])
stats.partner_link()
Usage
=====
@ -85,4 +96,4 @@ 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 http://odoo-community.org.
To contribute to this module, please visit https://odoo-community.org.

22
mass_mailing_partner/__init__.py

@ -1,20 +1,10 @@
# -*- coding: utf-8 -*-
# See README.rst file on addon root folder for license details
# © 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# © 2015 Antonio Espinosa <antonioea@antiun.com>
# © 2015 Javier Iniesta <javieria@antiun.com>
# © 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models
from . import wizard
from openerp import api, SUPERUSER_ID
def _match_existing_contacts(cr, registry):
with api.Environment.manage():
env = api.Environment(cr, SUPERUSER_ID, {})
contact_model = env['mail.mass_mailing.contact']
partner_model = env['res.partner']
contacts = contact_model.search([('email', '!=', False)])
for contact in contacts:
if contact.email:
partners = partner_model.search([('email', '=ilike',
contact.email)])
if partners:
contact.write({'partner_id': partners[0].id})
from .hooks import post_init_hook

14
mass_mailing_partner/__openerp__.py

@ -1,10 +1,15 @@
# -*- coding: utf-8 -*-
# See README.rst file on addon root folder for license details
# © 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# © 2015 Antonio Espinosa <antonioea@antiun.com>
# © 2015 Javier Iniesta <javieria@antiun.com>
# © 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Link partners with mass-mailing",
"version": "8.0.1.0.0",
"author": "Antiun Ingeniería S.L., "
"version": "8.0.2.0.0",
"author": "Tecnativa, "
"Antiun Ingeniería S.L., "
"Serv. Tecnol. Avanzados - Pedro M. Baeza, "
"Odoo Community Association (OCA)",
"license": "AGPL-3",
@ -12,8 +17,9 @@
"depends": [
'mass_mailing',
],
"post_init_hook": "_match_existing_contacts",
"post_init_hook": "post_init_hook",
'data': [
'views/mail_mail_statistics_view.xml',
'views/mail_mass_mailing_contact_view.xml',
'views/mail_mass_mailing_view.xml',
'views/res_partner_view.xml',

37
mass_mailing_partner/hooks.py

@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
# © 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# © 2015 Antonio Espinosa <antonioea@antiun.com>
# © 2015 Javier Iniesta <javieria@antiun.com>
# © 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
from openerp import api, SUPERUSER_ID
_logger = logging.getLogger(__name__)
def post_init_hook(cr, registry):
with api.Environment.manage():
env = api.Environment(cr, SUPERUSER_ID, {})
# ACTION 1: Match existing contacts
contact_model = env['mail.mass_mailing.contact']
partner_model = env['res.partner']
contacts = contact_model.search([('email', '!=', False)])
_logger.info('Trying to match %d contacts to partner by email',
len(contacts))
for contact in contacts:
partners = partner_model.search([
('email', '=ilike', contact.email)
], limit=1)
if partners:
contact.write({'partner_id': partners.id})
# ACTION 2: Match existing statistics
stat_model = env['mail.mail.statistics']
stats = stat_model.search([
('model', '!=', False),
('res_id', '!=', False),
])
_logger.info('Trying to link %d mass mailing statistics to partner',
len(stats))
stats.partner_link()

40
mass_mailing_partner/i18n/es.po

@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: crm (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-03-10 18:52+0000\n"
"PO-Revision-Date: 2016-03-10 18:54+0000\n"
"POT-Creation-Date: 2016-08-12 10:09+0000\n"
"PO-Revision-Date: 2016-08-08 12:35+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>\n"
"Language-Team: Spanish (http://www.transifex.com/oca/OCA-crm-8-0/language/es/)\n"
"MIME-Version: 1.0\n"
@ -48,11 +48,26 @@ msgstr "Creado por"
msgid "Created on"
msgstr "Creado en"
#. module: mass_mailing_partner
#: field:partner.mail.list.wizard,display_name:0
msgid "Display Name"
msgstr ""
#. module: mass_mailing_partner
#: model:ir.model,name:mass_mailing_partner.model_mail_mail_statistics
msgid "Email Statistics"
msgstr ""
#. module: mass_mailing_partner
#: field:partner.mail.list.wizard,id:0
msgid "ID"
msgstr "ID"
#. module: mass_mailing_partner
#: field:partner.mail.list.wizard,__last_update:0
msgid "Last Modified on"
msgstr ""
#. module: mass_mailing_partner
#: field:partner.mail.list.wizard,write_uid:0
msgid "Last Updated by"
@ -77,6 +92,7 @@ msgstr "Nº Listas de correo"
#. module: mass_mailing_partner
#: view:res.partner:mass_mailing_partner.view_partner_form
#: field:res.partner,mass_mailing_contacts:0
msgid "Mailing lists"
msgstr "Listas de correo"
@ -91,19 +107,27 @@ msgid "Mass Mailing Contact"
msgstr "Contacto de lista de correo"
#. module: mass_mailing_partner
#: field:res.partner,mass_mailing_contacts:0
msgid "Mass mailing contacts"
msgstr "Contactos de lista de correo"
#: view:res.partner:mass_mailing_partner.view_partner_form
#: field:res.partner,mass_mailing_stats:0
msgid "Mass mailing stats"
msgstr ""
#. module: mass_mailing_partner
#: field:res.partner,mass_mailing_stats_count:0
msgid "Mass mailing stats number"
msgstr ""
#. module: mass_mailing_partner
#: model:ir.model,name:mass_mailing_partner.model_res_partner
#: view:mail.mail.statistics:mass_mailing_partner.view_mail_mail_statistics_search
#: field:mail.mail.statistics,partner_id:0
#: view:mail.mass_mailing.contact:mass_mailing_partner.view_mail_mass_mailing_contact_search
#: field:mail.mass_mailing.contact,partner_id:0
msgid "Partner"
msgstr "Empresa"
#. module: mass_mailing_partner
#: code:addons/mass_mailing_partner/wizard/partner_mail_list_wizard.py:23
#: code:addons/mass_mailing_partner/wizard/partner_mail_list_wizard.py:26
#, python-format
msgid "Partner '%s' has no email."
msgstr "La empresa '%s' no tiene email."
@ -114,7 +138,7 @@ msgid "Partner Tag"
msgstr "Etiqueta de empresa"
#. module: mass_mailing_partner
#: code:addons/mass_mailing_partner/models/mail_mass_mailing_contact.py:15
#: code:addons/mass_mailing_partner/models/mail_mass_mailing_contact.py:19
#: sql_constraint:mail.mass_mailing.contact:0
#, python-format
msgid "Partner already exists in this mailing list."
@ -126,7 +150,7 @@ msgid "Partner ids"
msgstr "IDS de empresas"
#. module: mass_mailing_partner
#: code:addons/mass_mailing_partner/models/res_partner.py:23
#: code:addons/mass_mailing_partner/models/res_partner.py:33
#, python-format
msgid ""
"This partner '%s' is subscribed to one or more mailing lists. Email must be "

28
mass_mailing_partner/i18n/fr.po

@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: crm (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-06-30 00:51+0000\n"
"PO-Revision-Date: 2016-07-01 15:52+0000\n"
"POT-Creation-Date: 2016-08-12 10:09+0000\n"
"PO-Revision-Date: 2016-08-08 12:35+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>\n"
"Language-Team: French (http://www.transifex.com/oca/OCA-crm-8-0/language/fr/)\n"
"MIME-Version: 1.0\n"
@ -53,6 +53,11 @@ msgstr "Créé le"
msgid "Display Name"
msgstr "Nom d'affichage"
#. module: mass_mailing_partner
#: model:ir.model,name:mass_mailing_partner.model_mail_mail_statistics
msgid "Email Statistics"
msgstr ""
#. module: mass_mailing_partner
#: field:partner.mail.list.wizard,id:0
msgid "ID"
@ -87,6 +92,7 @@ msgstr ""
#. module: mass_mailing_partner
#: view:res.partner:mass_mailing_partner.view_partner_form
#: field:res.partner,mass_mailing_contacts:0
msgid "Mailing lists"
msgstr ""
@ -101,19 +107,27 @@ msgid "Mass Mailing Contact"
msgstr ""
#. module: mass_mailing_partner
#: field:res.partner,mass_mailing_contacts:0
msgid "Mass mailing contacts"
#: view:res.partner:mass_mailing_partner.view_partner_form
#: field:res.partner,mass_mailing_stats:0
msgid "Mass mailing stats"
msgstr ""
#. module: mass_mailing_partner
#: field:res.partner,mass_mailing_stats_count:0
msgid "Mass mailing stats number"
msgstr ""
#. module: mass_mailing_partner
#: model:ir.model,name:mass_mailing_partner.model_res_partner
#: view:mail.mail.statistics:mass_mailing_partner.view_mail_mail_statistics_search
#: field:mail.mail.statistics,partner_id:0
#: view:mail.mass_mailing.contact:mass_mailing_partner.view_mail_mass_mailing_contact_search
#: field:mail.mass_mailing.contact,partner_id:0
msgid "Partner"
msgstr "Contact"
#. module: mass_mailing_partner
#: code:addons/mass_mailing_partner/wizard/partner_mail_list_wizard.py:23
#: code:addons/mass_mailing_partner/wizard/partner_mail_list_wizard.py:26
#, python-format
msgid "Partner '%s' has no email."
msgstr ""
@ -124,7 +138,7 @@ msgid "Partner Tag"
msgstr ""
#. module: mass_mailing_partner
#: code:addons/mass_mailing_partner/models/mail_mass_mailing_contact.py:15
#: code:addons/mass_mailing_partner/models/mail_mass_mailing_contact.py:19
#: sql_constraint:mail.mass_mailing.contact:0
#, python-format
msgid "Partner already exists in this mailing list."
@ -136,7 +150,7 @@ msgid "Partner ids"
msgstr ""
#. module: mass_mailing_partner
#: code:addons/mass_mailing_partner/models/res_partner.py:23
#: code:addons/mass_mailing_partner/models/res_partner.py:33
#, python-format
msgid ""
"This partner '%s' is subscribed to one or more mailing lists. Email must be "

83
mass_mailing_partner/i18n/en.po → mass_mailing_partner/i18n/hr.po

@ -3,55 +3,61 @@
# * mass_mailing_partner
#
# Translators:
# Ana-Maria Olujić <ana-maria.olujic@slobodni-programi.hr>, 2016
msgid ""
msgstr ""
"Project-Id-Version: crm (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-05-07 11:40+0000\n"
"PO-Revision-Date: 2016-05-07 11:42+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>\n"
"Language-Team: English (http://www.transifex.com/oca/OCA-crm-8-0/language/en/)\n"
"POT-Creation-Date: 2016-08-15 00:49+0000\n"
"PO-Revision-Date: 2016-08-19 14:02+0000\n"
"Last-Translator: Ana-Maria Olujić <ana-maria.olujic@slobodni-programi.hr>\n"
"Language-Team: Croatian (http://www.transifex.com/oca/OCA-crm-8-0/language/hr/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: en\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Language: hr\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_partner
#: view:partner.mail.list.wizard:mass_mailing_partner.partner_mail_list_wizard_form
msgid "Add contacts to mailing list"
msgstr "Add contacts to mailing list"
msgstr "Dodaj kontakte na mailing listu"
#. module: mass_mailing_partner
#: model:ir.actions.act_window,name:mass_mailing_partner.action_partner_mail_list
msgid "Add to mailing list"
msgstr "Add to mailing list"
msgstr "Dodaj na mailing listu"
#. module: mass_mailing_partner
#: view:partner.mail.list.wizard:mass_mailing_partner.partner_mail_list_wizard_form
msgid "Cancel"
msgstr "Cancel"
msgstr "Otkaži"
#. module: mass_mailing_partner
#: model:ir.model,name:mass_mailing_partner.model_partner_mail_list_wizard
#: view:partner.mail.list.wizard:mass_mailing_partner.partner_mail_list_wizard_form
msgid "Create contact mailing list"
msgstr "Create contact mailing list"
msgstr "Kreiraj mailing listu"
#. module: mass_mailing_partner
#: field:partner.mail.list.wizard,create_uid:0
msgid "Created by"
msgstr "Created by"
msgstr "Kreirao/la"
#. module: mass_mailing_partner
#: field:partner.mail.list.wizard,create_date:0
msgid "Created on"
msgstr "Created on"
msgstr "Kreirano na dan"
#. module: mass_mailing_partner
#: field:partner.mail.list.wizard,display_name:0
msgid "Display Name"
msgstr "Display Name"
msgstr "Prikaži naziv"
#. module: mass_mailing_partner
#: model:ir.model,name:mass_mailing_partner.model_mail_mail_statistics
msgid "Email Statistics"
msgstr "Statistika e-maila"
#. module: mass_mailing_partner
#: field:partner.mail.list.wizard,id:0
@ -61,94 +67,103 @@ msgstr "ID"
#. module: mass_mailing_partner
#: field:partner.mail.list.wizard,__last_update:0
msgid "Last Modified on"
msgstr "Last Modified on"
msgstr "Zadnja izmjena"
#. module: mass_mailing_partner
#: field:partner.mail.list.wizard,write_uid:0
msgid "Last Updated by"
msgstr "Last Updated by"
msgstr "Zadnje ažuriranje izvršio/la"
#. module: mass_mailing_partner
#: field:partner.mail.list.wizard,write_date:0
msgid "Last Updated on"
msgstr "Last Updated on"
msgstr "Zadnje ažuriranje"
#. module: mass_mailing_partner
#: model:ir.model,name:mass_mailing_partner.model_mail_mass_mailing_list
#: field:partner.mail.list.wizard,mail_list_id:0
#: view:res.partner:mass_mailing_partner.view_res_partner_filter
msgid "Mailing List"
msgstr "Mailing List"
msgstr "Mailing lista"
#. module: mass_mailing_partner
#: field:res.partner,mass_mailing_contacts_count:0
msgid "Mailing list number"
msgstr "Mailing list number"
msgstr "Broj mailing liste"
#. module: mass_mailing_partner
#: view:res.partner:mass_mailing_partner.view_partner_form
#: field:res.partner,mass_mailing_contacts:0
msgid "Mailing lists"
msgstr "Mailing lists"
msgstr "Mailing liste"
#. module: mass_mailing_partner
#: field:mail.mass_mailing.list,partner_mandatory:0
msgid "Mandatory Partner"
msgstr "Mandatory Partner"
msgstr "Obavezan partner"
#. module: mass_mailing_partner
#: model:ir.model,name:mass_mailing_partner.model_mail_mass_mailing_contact
msgid "Mass Mailing Contact"
msgstr "Mass Mailing Contact"
msgstr "Kontakti za masovno slanje"
#. module: mass_mailing_partner
#: field:res.partner,mass_mailing_contacts:0
msgid "Mass mailing contacts"
msgstr "Mass mailing contacts"
#: view:res.partner:mass_mailing_partner.view_partner_form
#: field:res.partner,mass_mailing_stats:0
msgid "Mass mailing stats"
msgstr "Statistika masovnog slanja"
#. module: mass_mailing_partner
#: field:res.partner,mass_mailing_stats_count:0
msgid "Mass mailing stats number"
msgstr "Statistički pokazatelji masovnog slanja"
#. module: mass_mailing_partner
#: model:ir.model,name:mass_mailing_partner.model_res_partner
#: view:mail.mail.statistics:mass_mailing_partner.view_mail_mail_statistics_search
#: field:mail.mail.statistics,partner_id:0
#: view:mail.mass_mailing.contact:mass_mailing_partner.view_mail_mass_mailing_contact_search
#: field:mail.mass_mailing.contact,partner_id:0
msgid "Partner"
msgstr "Partner"
#. module: mass_mailing_partner
#: code:addons/mass_mailing_partner/wizard/partner_mail_list_wizard.py:23
#: code:addons/mass_mailing_partner/wizard/partner_mail_list_wizard.py:26
#, python-format
msgid "Partner '%s' has no email."
msgstr "Partner '%s' has no email."
msgstr "Partner '%s' nema e-mail "
#. module: mass_mailing_partner
#: field:mail.mass_mailing.list,partner_category:0
msgid "Partner Tag"
msgstr "Partner Tag"
msgstr "Oznaka partnera"
#. module: mass_mailing_partner
#: code:addons/mass_mailing_partner/models/mail_mass_mailing_contact.py:15
#: code:addons/mass_mailing_partner/models/mail_mass_mailing_contact.py:19
#: sql_constraint:mail.mass_mailing.contact:0
#, python-format
msgid "Partner already exists in this mailing list."
msgstr "Partner already exists in this mailing list."
msgstr "Partner već postoji na mailing listi."
#. module: mass_mailing_partner
#: field:partner.mail.list.wizard,partner_ids:0
msgid "Partner ids"
msgstr "Partner ids"
msgstr "ID partnera"
#. module: mass_mailing_partner
#: code:addons/mass_mailing_partner/models/res_partner.py:23
#: code:addons/mass_mailing_partner/models/res_partner.py:33
#, python-format
msgid ""
"This partner '%s' is subscribed to one or more mailing lists. Email must be "
"assigned."
msgstr "This partner '%s' is subscribed to one or more mailing lists. Email must be assigned."
msgstr "Ovaj partner '%s' već je preplaćen na jednu ili više mailing listi. E-mail mora biti dodijeljen."
#. module: mass_mailing_partner
#: view:partner.mail.list.wizard:mass_mailing_partner.partner_mail_list_wizard_form
msgid "or"
msgstr "or"
msgstr "ili"
#. module: mass_mailing_partner
#: view:mail.mass_mailing.contact:mass_mailing_partner.view_mail_mass_mailing_contact_tree
msgid "{'readonly': [('partner_id', '!=', False)]}"
msgstr "{'readonly': [('partner_id', '!=', False)]}"
msgstr ""

28
mass_mailing_partner/i18n/it.po

@ -9,8 +9,8 @@ msgid ""
msgstr ""
"Project-Id-Version: crm (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-05-07 11:40+0000\n"
"PO-Revision-Date: 2016-05-10 13:40+0000\n"
"POT-Creation-Date: 2016-08-12 10:09+0000\n"
"PO-Revision-Date: 2016-08-08 12:35+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>\n"
"Language-Team: Italian (http://www.transifex.com/oca/OCA-crm-8-0/language/it/)\n"
"MIME-Version: 1.0\n"
@ -55,6 +55,11 @@ msgstr "Creato il"
msgid "Display Name"
msgstr "Nome da visualizzare"
#. module: mass_mailing_partner
#: model:ir.model,name:mass_mailing_partner.model_mail_mail_statistics
msgid "Email Statistics"
msgstr ""
#. module: mass_mailing_partner
#: field:partner.mail.list.wizard,id:0
msgid "ID"
@ -89,6 +94,7 @@ msgstr ""
#. module: mass_mailing_partner
#: view:res.partner:mass_mailing_partner.view_partner_form
#: field:res.partner,mass_mailing_contacts:0
msgid "Mailing lists"
msgstr ""
@ -103,19 +109,27 @@ msgid "Mass Mailing Contact"
msgstr ""
#. module: mass_mailing_partner
#: field:res.partner,mass_mailing_contacts:0
msgid "Mass mailing contacts"
#: view:res.partner:mass_mailing_partner.view_partner_form
#: field:res.partner,mass_mailing_stats:0
msgid "Mass mailing stats"
msgstr ""
#. module: mass_mailing_partner
#: field:res.partner,mass_mailing_stats_count:0
msgid "Mass mailing stats number"
msgstr ""
#. module: mass_mailing_partner
#: model:ir.model,name:mass_mailing_partner.model_res_partner
#: view:mail.mail.statistics:mass_mailing_partner.view_mail_mail_statistics_search
#: field:mail.mail.statistics,partner_id:0
#: view:mail.mass_mailing.contact:mass_mailing_partner.view_mail_mass_mailing_contact_search
#: field:mail.mass_mailing.contact,partner_id:0
msgid "Partner"
msgstr "Partner"
#. module: mass_mailing_partner
#: code:addons/mass_mailing_partner/wizard/partner_mail_list_wizard.py:23
#: code:addons/mass_mailing_partner/wizard/partner_mail_list_wizard.py:26
#, python-format
msgid "Partner '%s' has no email."
msgstr ""
@ -126,7 +140,7 @@ msgid "Partner Tag"
msgstr "Tag Partner"
#. module: mass_mailing_partner
#: code:addons/mass_mailing_partner/models/mail_mass_mailing_contact.py:15
#: code:addons/mass_mailing_partner/models/mail_mass_mailing_contact.py:19
#: sql_constraint:mail.mass_mailing.contact:0
#, python-format
msgid "Partner already exists in this mailing list."
@ -138,7 +152,7 @@ msgid "Partner ids"
msgstr "ID Partner"
#. module: mass_mailing_partner
#: code:addons/mass_mailing_partner/models/res_partner.py:23
#: code:addons/mass_mailing_partner/models/res_partner.py:33
#, python-format
msgid ""
"This partner '%s' is subscribed to one or more mailing lists. Email must be "

30
mass_mailing_partner/i18n/sl.po

@ -8,8 +8,8 @@ msgid ""
msgstr ""
"Project-Id-Version: crm (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-05-07 11:40+0000\n"
"PO-Revision-Date: 2016-05-09 08:50+0000\n"
"POT-Creation-Date: 2016-08-12 10:09+0000\n"
"PO-Revision-Date: 2016-08-09 10:57+0000\n"
"Last-Translator: Matjaž Mozetič <m.mozetic@matmoz.si>\n"
"Language-Team: Slovenian (http://www.transifex.com/oca/OCA-crm-8-0/language/sl/)\n"
"MIME-Version: 1.0\n"
@ -54,6 +54,11 @@ msgstr "Ustvarjeno"
msgid "Display Name"
msgstr "Prikazni naziv"
#. module: mass_mailing_partner
#: model:ir.model,name:mass_mailing_partner.model_mail_mail_statistics
msgid "Email Statistics"
msgstr "E-poštna statistika"
#. module: mass_mailing_partner
#: field:partner.mail.list.wizard,id:0
msgid "ID"
@ -88,6 +93,7 @@ msgstr "Številka poštnega seznama"
#. module: mass_mailing_partner
#: view:res.partner:mass_mailing_partner.view_partner_form
#: field:res.partner,mass_mailing_contacts:0
msgid "Mailing lists"
msgstr "Poštni seznami"
@ -102,19 +108,27 @@ msgid "Mass Mailing Contact"
msgstr "Stik masovnega razpošiljanja"
#. module: mass_mailing_partner
#: field:res.partner,mass_mailing_contacts:0
msgid "Mass mailing contacts"
msgstr "Stiki masovnega razpošiljanja"
#: view:res.partner:mass_mailing_partner.view_partner_form
#: field:res.partner,mass_mailing_stats:0
msgid "Mass mailing stats"
msgstr "Statistika masovnega razpošiljanja"
#. module: mass_mailing_partner
#: field:res.partner,mass_mailing_stats_count:0
msgid "Mass mailing stats number"
msgstr "Število statistike masovnega razpošiljanja"
#. module: mass_mailing_partner
#: model:ir.model,name:mass_mailing_partner.model_res_partner
#: view:mail.mail.statistics:mass_mailing_partner.view_mail_mail_statistics_search
#: field:mail.mail.statistics,partner_id:0
#: view:mail.mass_mailing.contact:mass_mailing_partner.view_mail_mass_mailing_contact_search
#: field:mail.mass_mailing.contact,partner_id:0
msgid "Partner"
msgstr "Partner"
#. module: mass_mailing_partner
#: code:addons/mass_mailing_partner/wizard/partner_mail_list_wizard.py:23
#: code:addons/mass_mailing_partner/wizard/partner_mail_list_wizard.py:26
#, python-format
msgid "Partner '%s' has no email."
msgstr "Partner '%s' nima e-pošte."
@ -125,7 +139,7 @@ msgid "Partner Tag"
msgstr "Oznaka partnerja"
#. module: mass_mailing_partner
#: code:addons/mass_mailing_partner/models/mail_mass_mailing_contact.py:15
#: code:addons/mass_mailing_partner/models/mail_mass_mailing_contact.py:19
#: sql_constraint:mail.mass_mailing.contact:0
#, python-format
msgid "Partner already exists in this mailing list."
@ -137,7 +151,7 @@ msgid "Partner ids"
msgstr "ID-ji partnerjev"
#. module: mass_mailing_partner
#: code:addons/mass_mailing_partner/models/res_partner.py:23
#: code:addons/mass_mailing_partner/models/res_partner.py:33
#, python-format
msgid ""
"This partner '%s' is subscribed to one or more mailing lists. Email must be "

7
mass_mailing_partner/models/__init__.py

@ -1,6 +1,11 @@
# -*- coding: utf-8 -*-
# See README.rst file on addon root folder for license details
# © 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# © 2015 Antonio Espinosa <antonioea@antiun.com>
# © 2015 Javier Iniesta <javieria@antiun.com>
# © 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import mail_mass_mailing_contact
from . import res_partner
from . import mail_mass_mailing
from . import mail_mail_statistics

37
mass_mailing_partner/models/mail_mail_statistics.py

@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
# © 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import models, fields, api
class MailMailStatistics(models.Model):
_inherit = "mail.mail.statistics"
partner_id = fields.Many2one(
string="Partner", comodel_name='res.partner', readonly=True)
@api.model
def partner_id_from_obj(self, model, res_id):
partner_id = False
obj = self.env[model].browse(res_id)
if obj.exists():
if model == 'res.partner':
partner_id = res_id
elif 'partner_id' in obj._fields:
partner_id = obj.partner_id.id
return partner_id
@api.multi
def partner_link(self):
for stat in self.filtered(lambda r: r.model and r.res_id):
partner_id = self.partner_id_from_obj(stat.model, stat.res_id)
if partner_id != stat.partner_id.id:
stat.partner_id = partner_id
return True
@api.model
def create(self, vals):
stat = super(MailMailStatistics, self).create(vals)
stat.partner_link()
return stat

5
mass_mailing_partner/models/mail_mass_mailing.py

@ -1,5 +1,8 @@
# -*- coding: utf-8 -*-
# See README.rst file on addon root folder for license details
# © 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# © 2015 Antonio Espinosa <antonioea@antiun.com>
# © 2015 Javier Iniesta <javieria@antiun.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import models, fields

8
mass_mailing_partner/models/mail_mass_mailing_contact.py

@ -1,5 +1,9 @@
# -*- coding: utf-8 -*-
# See README.rst file on addon root folder for license details
# © 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# © 2015 Antonio Espinosa <antonioea@antiun.com>
# © 2015 Javier Iniesta <javieria@antiun.com>
# © 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import models, fields, api, _
@ -49,7 +53,7 @@ class MailMassMailingContact(models.Model):
def _set_partner(self, vals):
email = vals.get('email', self.email)
if not email:
if not email: # pragma: no cover
return vals
m_mailing = self.env['mail.mass_mailing.list']
m_partner = self.env['res.partner']

25
mass_mailing_partner/models/res_partner.py

@ -1,5 +1,9 @@
# -*- coding: utf-8 -*-
# See README.rst file on addon root folder for license details
# © 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# © 2015 Antonio Espinosa <antonioea@antiun.com>
# © 2015 Javier Iniesta <javieria@antiun.com>
# © 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import models, fields, api, _
from openerp.exceptions import ValidationError
@ -9,11 +13,17 @@ class ResPartner(models.Model):
_inherit = 'res.partner'
mass_mailing_contacts = fields.One2many(
string="Mailing lists",
comodel_name='mail.mass_mailing.contact', inverse_name='partner_id')
mass_mailing_contacts_count = fields.Integer(
string='Mailing list number', compute='_count_mass_mailing_contacts',
store=True)
string='Mailing list number',
compute='_compute_mass_mailing_contacts_count', store=True)
mass_mailing_stats = fields.One2many(
string="Mass mailing stats",
comodel_name='mail.mail.statistics', inverse_name='partner_id')
mass_mailing_stats_count = fields.Integer(
string='Mass mailing stats number',
compute='_compute_mass_mailing_stats_count', store=True)
@api.one
@api.constrains('email')
@ -25,9 +35,14 @@ class ResPartner(models.Model):
@api.one
@api.depends('mass_mailing_contacts')
def _count_mass_mailing_contacts(self):
def _compute_mass_mailing_contacts_count(self):
self.mass_mailing_contacts_count = len(self.mass_mailing_contacts)
@api.one
@api.depends('mass_mailing_stats')
def _compute_mass_mailing_stats_count(self):
self.mass_mailing_stats_count = len(self.mass_mailing_stats)
@api.multi
def write(self, vals):
res = super(ResPartner, self).write(vals)

6
mass_mailing_partner/tests/__init__.py

@ -1,5 +1,9 @@
# -*- coding: utf-8 -*-
# See README.rst file on addon root folder for license details
# © 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# © 2015 Antonio Espinosa <antonioea@antiun.com>
# © 2015 Javier Iniesta <javieria@antiun.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import test_mail_mass_mailing_contact, test_res_partner
from . import test_mail_mail_statistics
from . import test_partner_mail_list_wizard

5
mass_mailing_partner/tests/base.py

@ -1,5 +1,8 @@
# -*- coding: utf-8 -*-
# See README.rst file on addon root folder for license details
# © 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# © 2015 Antonio Espinosa <antonioea@antiun.com>
# © 2015 Javier Iniesta <javieria@antiun.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp.tests.common import TransactionCase

28
mass_mailing_partner/tests/test_mail_mail_statistics.py

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# © 2016 Antonio Espinosa <antonio.espinosa@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import base
class MailMailStatisticsCase(base.BaseCase):
def test_link_partner(self):
partner = self.create_partner(
{'name': 'Test partner'})
stat = self.env['mail.mail.statistics'].create({
'model': 'res.partner',
'res_id': partner.id,
})
self.assertEqual(partner.id, stat.partner_id.id)
def test_link_mail_contact(self):
partner = self.create_partner(
{'name': 'Test partner', 'email': 'test@domain.com'})
contact = self.create_mailing_contact(
{'partner_id': partner.id, 'list_id': self.mailing_list.id})
stat = self.env['mail.mail.statistics'].create({
'model': 'mail.mass_mailing.contact',
'res_id': contact.id,
})
self.assertEqual(partner.id, stat.partner_id.id)

20
mass_mailing_partner/tests/test_mail_mass_mailing_contact.py

@ -1,8 +1,11 @@
# -*- coding: utf-8 -*-
# See README.rst file on addon root folder for license details
# © 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# © 2015 Antonio Espinosa <antonioea@antiun.com>
# © 2015 Javier Iniesta <javieria@antiun.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import base
from .. import _match_existing_contacts
from ..hooks import post_init_hook
from psycopg2 import IntegrityError
@ -11,7 +14,7 @@ class MailMassMailingContactCase(base.BaseCase):
def test_match_existing_contacts(self):
contact = self.create_mailing_contact(
{'email': 'partner@test.com', 'list_id': self.mailing_list.id})
_match_existing_contacts(self.cr, self.registry)
post_init_hook(self.cr, self.registry)
self.assertEqual(contact.partner_id.id, self.partner.id)
def test_create_mass_mailing_contact(self):
@ -33,3 +36,14 @@ class MailMassMailingContactCase(base.BaseCase):
'list_id': self.mailing_list.id})
contact.write({'partner_id': False})
self.assertFalse(contact2.partner_id)
def test_onchange_partner(self):
contact = self.create_mailing_contact(
{'email': 'partner@test.com', 'list_id': self.mailing_list.id})
partner = self.create_partner(
{'name': 'Test partner', 'email': 'sample@test.com'})
with self.env.do_in_onchange():
contact.partner_id = partner
contact._onchange_partner()
self.assertEqual(contact.name, partner.name)
self.assertEqual(contact.email, partner.email)

5
mass_mailing_partner/tests/test_partner_mail_list_wizard.py

@ -1,5 +1,8 @@
# -*- coding: utf-8 -*-
# See README.rst file on addon root folder for license details
# © 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# © 2015 Antonio Espinosa <antonioea@antiun.com>
# © 2015 Javier Iniesta <javieria@antiun.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import base
from openerp.exceptions import Warning as UserError

6
mass_mailing_partner/tests/test_res_partner.py

@ -1,5 +1,8 @@
# -*- coding: utf-8 -*-
# See README.rst file on addon root folder for license details
# © 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# © 2015 Antonio Espinosa <antonioea@antiun.com>
# © 2015 Javier Iniesta <javieria@antiun.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import base
from openerp.exceptions import ValidationError
@ -12,7 +15,6 @@ class ResPartnerCase(base.BaseCase):
'list_id': self.mailing_list.id})
self.create_mailing_contact({'email': 'partner@test.com',
'list_id': self.mailing_list2.id})
self.partner._count_mass_mailing_contacts()
self.assertEqual(self.partner.mass_mailing_contacts_count, 2)
def test_write_res_partner(self):

46
mass_mailing_partner/views/mail_mail_statistics_view.xml

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- © 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<openerp>
<data>
<record model="ir.ui.view" id="view_mail_mail_statistics_form">
<field name="name">Add partner field</field>
<field name="model">mail.mail.statistics</field>
<field name="inherit_id" ref="mass_mailing.view_mail_mail_statistics_form"/>
<field name="arch" type="xml">
<field name="res_id" position="after">
<field name="partner_id"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_mail_mail_statistics_tree">
<field name="name">Add partner column</field>
<field name="model">mail.mail.statistics</field>
<field name="inherit_id" ref="mass_mailing.view_mail_mail_statistics_tree"/>
<field name="arch" type="xml">
<field name="sent" position="before">
<field name="partner_id"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="view_mail_mail_statistics_search">
<field name="name">Add partner search field and group by</field>
<field name="model">mail.mail.statistics</field>
<field name="inherit_id" ref="mass_mailing.view_mail_mail_statistics_search"/>
<field name="arch" type="xml">
<field name="mass_mailing_id" position="after">
<field name="partner_id"/>
</field>
<filter name="group_reply_date" position="after">
<filter string="Partner"
name="group_partner"
context="{'group_by': 'partner_id'}"/>
</filter>
</field>
</record>
</data>
</openerp>

7
mass_mailing_partner/views/mail_mass_mailing_contact_view.xml

@ -1,4 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- © 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
© 2015 Antonio Espinosa <antonioea@antiun.com>
© 2015 Javier Iniesta <javieria@antiun.com>
© 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<openerp>
<data>
@ -20,7 +25,7 @@
</record>
<record model="ir.ui.view" id="view_mail_mass_mailing_contact_search">
<field name="name">mail.mass_mailing.contact.search.partner</field>
<field name="name">Add partner search field and group by</field>
<field name="model">mail.mass_mailing.contact</field>
<field name="inherit_id" ref="mass_mailing.view_mail_mass_mailing_contact_search"/>
<field name="arch" type="xml">

4
mass_mailing_partner/views/mail_mass_mailing_view.xml

@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- © 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
© 2015 Antonio Espinosa <antonioea@antiun.com>
© 2015 Javier Iniesta <javieria@antiun.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<openerp>
<data>

15
mass_mailing_partner/views/res_partner_view.xml

@ -1,4 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- © 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
© 2015 Antonio Espinosa <antonioea@antiun.com>
© 2015 Javier Iniesta <javieria@antiun.com>
© 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<openerp>
<data>
@ -18,6 +23,16 @@
widget="statinfo"
string="Mailing lists"/>
</button>
<button name="%(mass_mailing.action_view_mail_mail_statistics)d"
context="{'search_default_partner_id': active_id,
'default_partner_id': active_id}"
type="action"
class="oe_stat_button oe_inline"
icon="fa-envelope-o">
<field name="mass_mailing_stats_count"
widget="statinfo"
string="Mass mailing stats"/>
</button>
</div>
</field>
</record>

5
mass_mailing_partner/wizard/__init__.py

@ -1,4 +1,7 @@
# -*- coding: utf-8 -*-
# See README.rst file on addon root folder for license details
# © 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# © 2015 Antonio Espinosa <antonioea@antiun.com>
# © 2015 Javier Iniesta <javieria@antiun.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import partner_mail_list_wizard

5
mass_mailing_partner/wizard/partner_mail_list_wizard.py

@ -1,5 +1,8 @@
# -*- coding: utf-8 -*-
# See README.rst file on addon root folder for license details
# © 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# © 2015 Antonio Espinosa <antonioea@antiun.com>
# © 2015 Javier Iniesta <javieria@antiun.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import models, api, fields, _
from openerp.exceptions import Warning as UserError

4
mass_mailing_partner/wizard/partner_mail_list_wizard.xml

@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- © 2015 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
© 2015 Antonio Espinosa <antonioea@antiun.com>
© 2015 Javier Iniesta <javieria@antiun.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<openerp>
<data>

Loading…
Cancel
Save