Create module mass_mailing_contact_active

pull/1096/head
Akim Juillerat 2022-03-22 14:59:14 +01:00 committed by Minh Chien
parent af3bf69ac1
commit 3f839a6523
9 changed files with 65 additions and 0 deletions

View File

@ -0,0 +1 @@
from . import models

View File

@ -0,0 +1,14 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
{
"name": "Mass Mailing Contact Active",
"summary": "Adds active feature on mailing list contact and subscriptions",
"version": "13.0.1.0.0",
"category": "Marketing/Email Marketing",
"website": "https://github.com/OCA/social",
"author": "Camptocamp, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": ["mass_mailing"],
}

View File

@ -0,0 +1,2 @@
from . import mailing_contact
from . import mailing_contact_subscription

View File

@ -0,0 +1,16 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo import fields, models
class MailingContact(models.Model):
_inherit = "mailing.contact"
active = fields.Boolean(default=True)
def write(self, values):
res = super().write(values)
if "active" in values:
self.mapped("subscription_list_ids").write({"active": values["active"]})
return res

View File

@ -0,0 +1,10 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo import fields, models
class MailingContactSubscription(models.Model):
_inherit = "mailing.contact.subscription"
active = fields.Boolean(default=True)

View File

@ -0,0 +1 @@
* Akim Juillerat <akim.juillerat@camptocamp.com>

View File

@ -0,0 +1 @@
This module adds an active field on mailing contact and subscription.

View File

@ -0,0 +1 @@
from . import test_mailing_contact_active

View File

@ -0,0 +1,19 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo.tests.common import SavepointCase
class TestMailingContactActive(SavepointCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.mailing_contact = cls.env.ref("mass_mailing.mass_mail_contact_1")
def test_archive_unarchive_mailing_contact(self):
self.assertTrue(self.mailing_contact.active)
subscription = self.mailing_contact.subscription_list_ids
self.assertTrue(subscription)
self.assertTrue(subscription.active)
self.mailing_contact.write({"active": False})
self.assertFalse(self.mailing_contact.active)
self.assertFalse(subscription.active)