[MIG] mass_mailing_partner: Migration to 13.0

This commit is contained in:
Manuel Calero 2020-02-10 11:40:11 +01:00 committed by emagdalenaC2i
parent eda99e3607
commit 7a5bc7090e
29 changed files with 130 additions and 130 deletions

View File

@ -14,16 +14,16 @@ Link partners with mass-mailing
: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/12.0/mass_mailing_partner
:target: https://github.com/OCA/social/tree/13.0/mass_mailing_partner
:alt: OCA/social
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/social-12-0/social-12-0-mass_mailing_partner
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/205/12.0
:target: https://runbot.odoo-community.org/runbot/205/13.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
|badge1| |badge2| |badge3| |badge4| |badge5|
This module links mass-mailing contacts with partners.
@ -61,7 +61,7 @@ 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:%20mass_mailing_partner%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/social/issues/new?body=module:%20mass_mailing_partner%0Aversion:%2013.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.
@ -86,6 +86,7 @@ Contributors
* David Vidal
* Ernesto Tejeda
* Victor M.M. Torres
* Manuel Calero
Maintainers
~~~~~~~~~~~
@ -100,6 +101,6 @@ 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/12.0/mass_mailing_partner>`_ project on GitHub.
This module is part of the `OCA/social <https://github.com/OCA/social/tree/13.0/mass_mailing_partner>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -1,6 +1,3 @@
# Copyright 2015 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# Copyright 2015 Antonio Espinosa <antonio.espinosa@tecnativa.com>
# Copyright 2015 Javier Iniesta <javieria@antiun.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models

View File

@ -1,11 +1,12 @@
# Copyright 2015 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# Copyright 2015-2016 Antonio Espinosa <antonio.espinosa@tecnativa.com>
# Copyright 2015 Javier Iniesta <javieria@antiun.com>
# Copyright 2020 Tecnativa - Manuel Calero
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Link partners with mass-mailing",
"version": "12.0.1.0.2",
"version": "13.0.1.0.0",
"author": "Tecnativa, " "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/social",
"license": "AGPL-3",
@ -13,9 +14,9 @@
"depends": ["mass_mailing"],
"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/mailing_trace_view.xml",
"views/mailing_contact_view.xml",
"views/mailing_view.xml",
"views/res_partner_view.xml",
"wizard/partner_mail_list_wizard.xml",
],

View File

@ -2,6 +2,7 @@
# Copyright 2015 Antonio Espinosa <antonio.espinosa@tecnativa.com>
# Copyright 2015 Javier Iniesta <javieria@antiun.com>
# Copyright 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com>
# Copyright 2020 Tecnativa - Manuel Calero
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
@ -15,7 +16,7 @@ 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"]
contact_model = env["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))
@ -26,7 +27,7 @@ def post_init_hook(cr, registry):
if partners:
contact.write({"partner_id": partners.id})
# ACTION 2: Match existing statistics
stat_model = env["mail.mail.statistics"]
stat_model = env["mailing.trace"]
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()

View File

@ -11,7 +11,7 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-02-26 01:46+0000\n"
"PO-Revision-Date: 2018-02-26 01:46+0000\n"
"Last-Translator: enjolras <yo@miguelrevilla.com>, 2017\n"
"Last-Translator: Tecnativa - Manuel Calero, 2020\n"
"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n"
"Language: es\n"
"MIME-Version: 1.0\n"
@ -24,7 +24,7 @@ msgstr ""
#: code:addons/mass_mailing_partner/models/mail_mass_mailing_list_contact_rel.py:17
#, python-format
msgid "A partner cannot be multiple times in the same list"
msgstr ""
msgstr "Un cliente no puede estar varias veces en la misma lista"
#. module: mass_mailing_partner
#: model_terms:ir.ui.view,arch_db:mass_mailing_partner.partner_mail_list_wizard_form
@ -44,7 +44,7 @@ msgstr "Cancelar"
#. module: mass_mailing_partner
#: model:ir.model,name:mass_mailing_partner.model_res_partner
msgid "Contact"
msgstr ""
msgstr "Contacto"
#. module: mass_mailing_partner
#: model:ir.model,name:mass_mailing_partner.model_partner_mail_list_wizard
@ -127,7 +127,7 @@ msgstr "Contacto de envío masivo"
#. module: mass_mailing_partner
#: model:ir.model,name:mass_mailing_partner.model_mail_mass_mailing_list_contact_rel
msgid "Mass Mailing Subscription Information"
msgstr ""
msgstr "Información de suscripción de correo masivo"
#. module: mass_mailing_partner
#: model:ir.model.fields,field_description:mass_mailing_partner.field_res_partner__mass_mailing_stats_ids

View File

@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"

View File

@ -1,10 +1,7 @@
# Copyright 2015 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# Copyright 2015 Antonio Espinosa <antonio.espinosa@tecnativa.com>
# Copyright 2015 Javier Iniesta <javieria@antiun.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import mail_mass_mailing_contact
from . import mailing_contact
from . import mailing_list
from . import mailing_trace
from . import mailing_contact_subscription
from . import res_partner
from . import mail_mass_mailing
from . import mail_mail_statistics
from . import mail_mass_mailing_list_contact_rel

View File

@ -2,14 +2,15 @@
# Copyright 2015 Antonio Espinosa <antonio.espinosa@tecnativa.com>
# Copyright 2015 Javier Iniesta <javieria@antiun.com>
# Copyright 2017 David Vidal <david.vidal@tecnativa.com>
# Copyright 2020 Tecnativa - Manuel Calero
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
class MailMassMailingContact(models.Model):
_inherit = "mail.mass_mailing.contact"
class MailingContact(models.Model):
_inherit = "mailing.contact"
partner_id = fields.Many2one(
comodel_name="res.partner", string="Partner", domain=[("email", "!=", False)]
@ -53,7 +54,7 @@ class MailMassMailingContact(models.Model):
subscription_list_ids=vals.get("subscription_list_ids", False),
list_ids=vals.get("list_ids", False),
)
return super(MailMassMailingContact, self).create(new_vals)
return super(MailingContact, self).create(new_vals)
def write(self, vals):
for contact in self:
@ -67,7 +68,7 @@ class MailMassMailingContact(models.Model):
subscription_list_ids=vals.get("subscription_list_ids", False),
list_ids=vals.get("list_ids", False),
)
super(MailMassMailingContact, contact).write(new_vals)
super(MailingContact, contact).write(new_vals)
return True
def _get_company(self):
@ -96,7 +97,6 @@ class MailMassMailingContact(models.Model):
"category_id": self._get_categories(),
}
@api.multi
def _set_partner(self):
self.ensure_one()
m_partner = self.env["res.partner"]

View File

@ -1,12 +1,13 @@
# Copyright 2018 Tecnativa - Ernesto Tejeda
# Copyright 2020 Tecnativa - Manuel Calero
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import _, api, models
from odoo.exceptions import ValidationError
class MassMailingContactListRel(models.Model):
_inherit = "mail.mass_mailing.list_contact_rel"
class MailingContactSubscription(models.Model):
_inherit = "mailing.contact.subscription"
@api.constrains("contact_id", "list_id")
def _check_contact_id_partner_id_list_id(self):
@ -15,5 +16,5 @@ class MassMailingContactListRel(models.Model):
contacts = rel.list_id.contact_ids - rel.contact_id
if rel.contact_id.partner_id in contacts.mapped("partner_id"):
raise ValidationError(
_("A partner cannot be multiple " "times in the same list")
_("A partner cannot be multiple times in the same list")
)

View File

@ -1,14 +1,15 @@
# Copyright 2015 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# Copyright 2015 Antonio Espinosa <antonio.espinosa@tecnativa.com>
# Copyright 2015 Javier Iniesta <javieria@antiun.com>
# Copyright 2020 Tecnativa - Manuel Calero
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
class MailMassMailingList(models.Model):
_inherit = "mail.mass_mailing.list"
class MailingList(models.Model):
_inherit = "mailing.list"
partner_mandatory = fields.Boolean(string="Mandatory Partner", default=False)
partner_category = fields.Many2one(
@ -17,7 +18,7 @@ class MailMassMailingList(models.Model):
@api.constrains("contact_ids")
def _check_contact_ids_partner_id(self):
contact_obj = self.env["mail.mass_mailing.contact"]
contact_obj = self.env["mailing.contact"]
for mailing_list in self:
data = contact_obj.read_group(
[

View File

@ -1,11 +1,12 @@
# Copyright 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com>
# Copyright 2020 Tecnativa - Manuel Calero
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
class MailMailStatistics(models.Model):
_inherit = "mail.mail.statistics"
class MailingTrace(models.Model):
_inherit = "mailing.trace"
partner_id = fields.Many2one(
string="Partner", comodel_name="res.partner", readonly=True
@ -31,6 +32,6 @@ class MailMailStatistics(models.Model):
@api.model
def create(self, vals):
stat = super(MailMailStatistics, self).create(vals)
stat = super(MailingTrace, self).create(vals)
stat.partner_link()
return stat

View File

@ -2,6 +2,7 @@
# Copyright 2015 Antonio Espinosa <antonio.espinosa@tecnativa.com>
# Copyright 2015 Javier Iniesta <javieria@antiun.com>
# Copyright 2017 David Vidal <david.vidal@tecnativa.com>
# Copyright 2020 Tecnativa - Manuel Calero
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import _, api, fields, models
@ -13,7 +14,7 @@ class ResPartner(models.Model):
mass_mailing_contact_ids = fields.One2many(
string="Mailing contacts",
comodel_name="mail.mass_mailing.contact",
comodel_name="mailing.contact",
inverse_name="partner_id",
)
mass_mailing_contacts_count = fields.Integer(
@ -24,7 +25,7 @@ class ResPartner(models.Model):
)
mass_mailing_stats_ids = fields.One2many(
string="Mass mailing stats",
comodel_name="mail.mail.statistics",
comodel_name="mailing.trace",
inverse_name="partner_id",
)
mass_mailing_stats_count = fields.Integer(
@ -47,24 +48,24 @@ class ResPartner(models.Model):
@api.depends("mass_mailing_contact_ids")
def _compute_mass_mailing_contacts_count(self):
contact_data = self.env["mail.mass_mailing.contact"].read_group(
contact_data = self.env["mailing.contact"].read_group(
[("partner_id", "in", self.ids)], ["partner_id"], ["partner_id"]
)
mapped_data = {
contact["partner_id"][0]: contact["partner_id_count"]
for contact in contact_data
contact["partner_id"][0]: contact["partner_id_count"]
for contact in contact_data
}
for partner in self:
partner.mass_mailing_contacts_count = mapped_data.get(partner.id, 0)
@api.depends("mass_mailing_stats_ids")
def _compute_mass_mailing_stats_count(self):
contact_data = self.env["mail.mail.statistics"].read_group(
contact_data = self.env["mailing.trace"].read_group(
[("partner_id", "in", self.ids)], ["partner_id"], ["partner_id"]
)
mapped_data = {
contact["partner_id"][0]: contact["partner_id_count"]
for contact in contact_data
contact["partner_id"][0]: contact["partner_id_count"]
for contact in contact_data
}
for partner in self:
partner.mass_mailing_stats_count = mapped_data.get(partner.id, 0)
@ -87,7 +88,7 @@ class ResPartner(models.Model):
mm_vals["tag_ids"] = vals["category_id"]
if mm_vals:
# Using sudo because ACLs shouldn't produce data inconsistency
self.env["mail.mass_mailing.contact"].sudo().search(
self.env["mailing.contact"].sudo().search(
[("partner_id", "in", self.ids)]
).write(mm_vals)
return res

View File

@ -8,3 +8,4 @@
* David Vidal
* Ernesto Tejeda
* Victor M.M. Torres
* Manuel Calero

View File

@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/social/tree/12.0/mass_mailing_partner"><img alt="OCA/social" src="https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/social-12-0/social-12-0-mass_mailing_partner"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/205/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/social/tree/13.0/mass_mailing_partner"><img alt="OCA/social" src="https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/social-13-0/social-13-0-mass_mailing_partner"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/205/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module links mass-mailing contacts with partners.</p>
<div class="section" id="features">
<h1>Features</h1>
@ -404,7 +404,7 @@ as mailing list contacts.</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/social/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/social/issues/new?body=module:%20mass_mailing_partner%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/social/issues/new?body=module:%20mass_mailing_partner%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
@ -443,7 +443,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/social/tree/12.0/mass_mailing_partner">OCA/social</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/social/tree/13.0/mass_mailing_partner">OCA/social</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@ -1,6 +1,3 @@
# Copyright 2015 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# Copyright 2015 Antonio Espinosa <antonio.espinosa@tecnativa.com>
# Copyright 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

View File

@ -1,6 +1,7 @@
# Copyright 2015 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# Copyright 2015 Antonio Espinosa <antonio.espinosa@tecnativa.com>
# Copyright 2015 Javier Iniesta <javieria@antiun.com>
# Copyright 2020 Tecnativa - Manuel Calero
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo.tests.common import TransactionCase
@ -41,11 +42,11 @@ class BaseCase(TransactionCase):
return m_partner.create(vals)
def create_mailing_contact(self, vals):
m_mailing_contact = self.env["mail.mass_mailing.contact"]
m_mailing_contact = self.env["mailing.contact"]
return m_mailing_contact.create(vals)
def create_mailing_list(self, vals):
m_mailing_list = self.env["mail.mass_mailing.list"]
m_mailing_list = self.env["mailing.list"]
return m_mailing_list.create(vals)
def check_mailing_contact_partner(self, mailing_contact):

View File

@ -1,6 +1,7 @@
# Copyright 2015 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# Copyright 2015 Antonio Espinosa <antonio.espinosa@tecnativa.com>
# Copyright 2015 Javier Iniesta <javieria@antiun.com>
# Copyright 2020 Tecnativa - Manuel Calero
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import base
@ -9,7 +10,7 @@ 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(
stat = self.env["mailing.trace"].create(
{"model": "res.partner", "res_id": partner.id}
)
self.assertEqual(partner.id, stat.partner_id.id)
@ -23,7 +24,7 @@ class MailMailStatisticsCase(base.BaseCase):
"list_ids": [[6, 0, [self.mailing_list.id]]],
}
contact = self.create_mailing_contact(contact_vals)
stat = self.env["mail.mail.statistics"].create(
{"model": "mail.mass_mailing.contact", "res_id": contact.id}
stat = self.env["mailing.trace"].create(
{"model": "mailing.contact", "res_id": contact.id}
)
self.assertEqual(partner.id, stat.partner_id.id)

View File

@ -1,6 +1,7 @@
# Copyright 2015 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# Copyright 2015 Antonio Espinosa <antonio.espinosa@tecnativa.com>
# Copyright 2015 Javier Iniesta <javieria@antiun.com>
# Copyright 2020 Tecnativa - Manuel Calero
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo.exceptions import ValidationError
@ -104,7 +105,7 @@ class MailMassMailingContactCase(base.BaseCase):
"category_id": [(6, 0, (category_8 | category_11).ids)],
}
partner = self.create_partner(partner_vals)
with self.env.do_in_onchange():
contact.partner_id = partner
contact._onchange_partner_mass_mailing_partner()
self.check_mailing_contact_partner(contact)
# with self.env.do_in_onchange():
contact.partner_id = partner
contact._onchange_partner_mass_mailing_partner()
self.check_mailing_contact_partner(contact)

View File

@ -1,4 +1,5 @@
# Copyright 2018 Tecnativa - Ernesto tejeda
# Copyright 2020 Tecnativa - Manuel Calero
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo.exceptions import ValidationError
@ -33,9 +34,6 @@ class MailMassMailingListCase(base.BaseCase):
self.create_mailing_list(
{
"name": "List test 3",
"subscription_contact_ids": [
(0, 0, {"contact_id": contact_test_1.id}),
(0, 0, {"contact_id": contact_test_2.id}),
],
"contact_ids": [(4, contact_test_1.id), (4, contact_test_2.id)],
}
)

View File

@ -1,4 +1,5 @@
# Copyright 2018 Tecnativa - Ernesto tejeda
# Copyright 2020 Tecnativa - Manuel Calero
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo.exceptions import ValidationError
@ -14,13 +15,8 @@ class MailMassMailingListContactRelCase(base.BaseCase):
contact_test_2 = self.create_mailing_contact(
{"name": "Contact test 2", "partner_id": self.partner.id}
)
list_3 = self.create_mailing_list({"name": "List test 3"})
self.env["mail.mass_mailing.list_contact_rel"].create(
{"list_id": list_3.id, "contact_id": contact_test_1.id}
list_3 = self.create_mailing_list(
{"name": "List test 3", "contact_ids": [(4, contact_test_1.id)]}
)
with self.assertRaises(ValidationError):
self.env["mail.mass_mailing.list_contact_rel"].create(
{"list_id": list_3.id, "contact_id": contact_test_2.id}
)
list_3.contact_ids = [(4, contact_test_2.id)]

View File

@ -1,6 +1,7 @@
# Copyright 2015 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# Copyright 2015 Antonio Espinosa <antonio.espinosa@tecnativa.com>
# Copyright 2015 Javier Iniesta <javieria@antiun.com>
# Copyright 2020 Tecnativa - Manuel Calero
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo.exceptions import UserError
@ -15,7 +16,7 @@ class PartnerMailListWizardCase(base.BaseCase):
)
wizard.partner_ids = [self.partner.id]
wizard.add_to_mail_list()
contacts = self.env["mail.mass_mailing.contact"].search(
contacts = self.env["mailing.contact"].search(
[("partner_id", "=", self.partner.id)]
)
cont = contacts.filtered(lambda r: wizard.mail_list_id in r.list_ids)
@ -24,6 +25,7 @@ class PartnerMailListWizardCase(base.BaseCase):
# This line does not create a new contact
wizard.add_to_mail_list()
self.assertEqual(len(self.partner.mass_mailing_contact_ids), 1)
self.assertEqual(
self.partner.mass_mailing_contact_ids.list_ids, self.mailing_list
)

View File

@ -1,6 +1,7 @@
# Copyright 2015 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# Copyright 2015 Antonio Espinosa <antonio.espinosa@tecnativa.com>
# Copyright 2015 Javier Iniesta <javieria@antiun.com>
# Copyright 2020 Tecnativa - Manuel Calero
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo.exceptions import ValidationError

View File

@ -3,12 +3,13 @@
Copyright 2015 Antonio Espinosa <antonio.espinosa@tecnativa.com>
Copyright 2015 Javier Iniesta <javieria@antiun.com>
Copyright 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com>
Copyright 2020 Tecnativa - Manuel Calero
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<odoo>
<record model="ir.ui.view" id="view_mail_mass_mailing_contact_tree">
<field name="name">mail.mass_mailing.contact.tree.inherit</field>
<field name="model">mail.mass_mailing.contact</field>
<field name="name">mailing.contact.tree.inherit</field>
<field name="model">mailing.contact</field>
<field name="inherit_id" ref="mass_mailing.view_mail_mass_mailing_contact_tree"/>
<field name="arch" type="xml">
<field name="email" position="after">
@ -18,8 +19,8 @@
</record>
<record model="ir.ui.view" id="view_mail_mass_mailing_contact_form">
<field name="name">mail.mass_mailing.contact.form.partner</field>
<field name="model">mail.mass_mailing.contact</field>
<field name="name">mailing.contact.form.partner</field>
<field name="model">mailing.contact</field>
<field name="inherit_id" ref="mass_mailing.view_mail_mass_mailing_contact_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='email']/.." position="after">
@ -48,7 +49,7 @@
<record model="ir.ui.view" id="view_mail_mass_mailing_contact_search">
<field name="name">Add partner search field and group by</field>
<field name="model">mail.mass_mailing.contact</field>
<field name="model">mailing.contact</field>
<field name="inherit_id" ref="mass_mailing.view_mail_mass_mailing_contact_search"/>
<field name="arch" type="xml">
<field name="name" position="after">

View File

@ -1,12 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com>
Copyright 2020 Tecnativa - Manuel Calero
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<odoo>
<record model="ir.ui.view" id="view_mail_mail_statistics_form">
<record model="ir.ui.view" id="mailing_trace_view_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="model">mailing.trace</field>
<field name="inherit_id" ref="mass_mailing.mailing_trace_view_form"/>
<field name="arch" type="xml">
<field name="res_id" position="after">
<field name="partner_id"/>
@ -14,10 +15,10 @@
</field>
</record>
<record model="ir.ui.view" id="view_mail_mail_statistics_tree">
<record model="ir.ui.view" id="mailing_trace_view_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="model">mailing.trace</field>
<field name="inherit_id" ref="mass_mailing.mailing_trace_view_tree"/>
<field name="arch" type="xml">
<field name="sent" position="before">
<field name="partner_id"/>
@ -25,10 +26,10 @@
</field>
</record>
<record model="ir.ui.view" id="view_mail_mail_statistics_search">
<record model="ir.ui.view" id="mailing_trace_view_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="model">mailing.trace</field>
<field name="inherit_id" ref="mass_mailing.mailing_trace_view_search"/>
<field name="arch" type="xml">
<field name="mass_mailing_id" position="after">
<field name="partner_id"/>

View File

@ -2,13 +2,14 @@
<!-- Copyright 2015 Pedro M. Baeza <pedro.baeza@tecnativa.com>
Copyright 2015 Antonio Espinosa <antonio.espinosa@tecnativa.com>
Copyright 2015 Javier Iniesta <javieria@antiun.com>
Copyright 2020 Tecnativa - Manuel Calero
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<odoo>
<record model="ir.ui.view" id="view_mail_mass_mailing_list_form">
<field name="name">mail.mass_mailing.list.form</field>
<field name="model">mail.mass_mailing.list</field>
<field name="inherit_id" ref="mass_mailing.view_mail_mass_mailing_list_form"/>
<record model="ir.ui.view" id="mailing_list_view_form">
<field name="name">mailing.list.form</field>
<field name="model">mailing.list</field>
<field name="inherit_id" ref="mass_mailing.mailing_list_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[hasclass('oe_title')]" position="after">
<group>

View File

@ -3,6 +3,7 @@
Copyright 2015-16 Antonio Espinosa <antonio.espinosa@tecnativa.com>
Copyright 2015 Javier Iniesta <javieria@antiun.com>
Copyright 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com>
Copyright 2020 Tecnativa - Manuel Calero
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<odoo>
@ -23,7 +24,7 @@
widget="statinfo"
string="Mailing contacts"/>
</button>
<button name="%(mass_mailing.action_view_mail_mail_statistics)d"
<button name="%(mass_mailing.action_view_mail_mail_statistics_mailing)d"
context="{'search_default_partner_id': active_id,
'default_partner_id': active_id}"
type="action"

View File

@ -1,6 +1,3 @@
# Copyright 2015 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# Copyright 2015 Antonio Espinosa <antonio.espinosa@tecnativa.com>
# Copyright 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

View File

@ -1,9 +1,10 @@
# Copyright 2015 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# Copyright 2015 Antonio Espinosa <antonio.espinosa@tecnativa.com>
# Copyright 2015 Javier Iniesta <javieria@antiun.com>
# Copyright 2020 Tecnativa - Manuel Calero
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import _, api, fields, models
from odoo import _, fields, models
from odoo.exceptions import UserError
@ -11,23 +12,22 @@ class PartnerMailListWizard(models.TransientModel):
_name = "partner.mail.list.wizard"
_description = "Create contact mailing list"
mail_list_id = fields.Many2one(
comodel_name="mail.mass_mailing.list", string="Mailing List"
)
mail_list_id = fields.Many2one(comodel_name="mailing.list", string="Mailing List")
partner_ids = fields.Many2many(
comodel_name="res.partner",
relation="mail_list_wizard_partner",
default=lambda self: self.env.context.get("active_ids"),
)
@api.multi
def add_to_mail_list(self):
contact_obj = self.env["mail.mass_mailing.contact"]
contact_obj = self.env["mailing.contact"]
partners = self.partner_ids
add_list = partners.filtered("mass_mailing_contact_ids")
for partner in add_list:
partner.mass_mailing_contact_ids[0].list_ids |= self.mail_list_id
self.mail_list_id.contact_ids = [
(4, partner.mass_mailing_contact_ids[0].id)
]
to_create = partners - add_list
for partner in to_create:
@ -35,7 +35,7 @@ class PartnerMailListWizard(models.TransientModel):
raise UserError(_("Partner '%s' has no email.") % partner.name)
contact_vals = {
"partner_id": partner.id,
"list_ids": [[6, 0, [self.mail_list_id.id]]],
"list_ids": [(4, self.mail_list_id.id)],
"title_id": partner.title or False,
"company_name": partner.company_id.name or False,
"country_id": partner.country_id or False,

View File

@ -2,32 +2,32 @@
<!-- Copyright 2015 Pedro M. Baeza <pedro.baeza@tecnativa.com>
Copyright 2015 Antonio Espinosa <antonio.espinosa@tecnativa.com>
Copyright 2015 Javier Iniesta <javieria@antiun.com>
Copyright 2020 Tecnativa - Manuel Calero
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<odoo>
<act_window name="Add to mailing list"
res_model="partner.mail.list.wizard"
src_model="res.partner"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_partner_mail_list"/>
<act_window id="action_partner_mail_list"
name="Add to mailing list"
res_model="partner.mail.list.wizard"
binding_model="res.partner"
target="new"
view_mode="form"/>
<record model="ir.ui.view" id="partner_mail_list_wizard_form">
<field name="name">partner.mail.list.form</field>
<field name="model">partner.mail.list.wizard</field>
<field name="arch" type="xml">
<form string="Create contact mailing list">
<group>
<field name="mail_list_id"/>
</group>
<footer>
<button string="Add contacts to mailing list" name="add_to_mail_list"
type="object" class="oe_highlight"/>
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>
</field>
</record>
<record model="ir.ui.view" id="partner_mail_list_wizard_form">
<field name="name">partner.mail.list.form</field>
<field name="model">partner.mail.list.wizard</field>
<field name="arch" type="xml">
<form string="Create contact mailing list">
<group>
<field name="mail_list_id"/>
</group>
<footer>
<button string="Add contacts to mailing list" name="add_to_mail_list"
type="object" class="oe_highlight"/>
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>
</field>
</record>
</odoo>