2020-02-05 10:34:32 +01:00
|
|
|
# Copyright 2017-2020 Tecnativa - Pedro M. Baeza
|
2018-01-23 13:36:17 +01:00
|
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
|
|
|
|
|
|
|
|
|
|
|
from odoo import _, exceptions, models
|
|
|
|
|
|
|
|
|
2020-02-05 10:34:32 +01:00
|
|
|
class MailingMailing(models.Model):
|
|
|
|
_inherit = "mailing.mailing"
|
2018-01-23 13:36:17 +01:00
|
|
|
|
|
|
|
def button_draft(self):
|
|
|
|
"""Return to draft state for resending the mass mailing."""
|
2020-02-05 10:32:10 +01:00
|
|
|
if any(self.mapped(lambda x: x.state != "done")):
|
2018-01-23 13:36:17 +01:00
|
|
|
raise exceptions.UserError(
|
2020-02-05 10:32:10 +01:00
|
|
|
_(
|
|
|
|
"You can't resend a mass mailing that is being sent or in "
|
|
|
|
"draft state."
|
|
|
|
)
|
2018-01-23 13:36:17 +01:00
|
|
|
)
|
2020-02-05 10:32:10 +01:00
|
|
|
self.write({"state": "draft"})
|