[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). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models from . import models

View File

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

View File

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