[IMP] : black, isort

This commit is contained in:
Pedro M. Baeza 2020-02-05 10:32:10 +01:00 committed by Víctor Martínez
parent 05a25ecc76
commit ff882a0353
4 changed files with 28 additions and 33 deletions

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models

View File

@ -7,15 +7,10 @@
"version": "12.0.1.0.0",
"category": "Marketing",
"website": "https://github.com/OCA/social",
"author": "Tecnativa, "
"Odoo Community Association (OCA)",
"author": "Tecnativa, " "Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"mass_mailing",
],
"data": [
"views/mass_mailing_views.xml",
],
"depends": ["mass_mailing"],
"data": ["views/mass_mailing_views.xml"],
}

View File

@ -10,9 +10,11 @@ class MailMassMailingList(models.Model):
def button_draft(self):
"""Return to draft state for resending the mass mailing."""
if any(self.mapped(lambda x: x.state != 'done')):
if any(self.mapped(lambda x: x.state != "done")):
raise exceptions.UserError(
_("You can't resend a mass mailing that is being sent or in "
"draft state.")
_(
"You can't resend a mass mailing that is being sent or in "
"draft state."
)
self.write({'state': 'draft'})
)
self.write({"state": "draft"})

View File

@ -1,37 +1,36 @@
# Copyright 2017-2018 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo.tests import common
from odoo import exceptions
from odoo.tests import common
class TestMassMailingResend(common.SavepointCase):
@classmethod
def setUpClass(cls):
super(TestMassMailingResend, cls).setUpClass()
cls.list = cls.env['mail.mass_mailing.list'].create({
'name': 'Test list',
})
cls.contact1 = cls.env['mail.mass_mailing.contact'].create({
'name': 'Contact 1',
'email': 'email1@test.com',
})
cls.mass_mailing = cls.env['mail.mass_mailing'].create({
'name': 'Test mass mailing',
'email_from': 'test@example.org',
'mailing_model_id': cls.env.ref(
'mass_mailing.model_mail_mass_mailing_contact'
cls.list = cls.env["mail.mass_mailing.list"].create({"name": "Test list"})
cls.contact1 = cls.env["mail.mass_mailing.contact"].create(
{"name": "Contact 1", "email": "email1@test.com"}
)
cls.mass_mailing = cls.env["mail.mass_mailing"].create(
{
"name": "Test mass mailing",
"email_from": "test@example.org",
"mailing_model_id": cls.env.ref(
"mass_mailing.model_mail_mass_mailing_contact"
).id,
'contact_list_ids': [(6, 0, cls.list.ids)],
'reply_to_mode': 'thread',
})
"contact_list_ids": [(6, 0, cls.list.ids)],
"reply_to_mode": "thread",
}
)
def test_resend_error(self):
with self.assertRaises(exceptions.UserError):
self.mass_mailing.button_draft()
def test_resend(self):
self.mass_mailing.state = 'done' # Force state
self.assertEqual(self.mass_mailing.state, 'done')
self.mass_mailing.state = "done" # Force state
self.assertEqual(self.mass_mailing.state, "done")
self.mass_mailing.button_draft()
self.assertEqual(self.mass_mailing.state, 'draft')
self.assertEqual(self.mass_mailing.state, "draft")