-
-
Notifications
You must be signed in to change notification settings - Fork 603
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] mass_mailing_custom_unsubscribe: Migration to 12.0
- Loading branch information
1 parent
907546c
commit 791dec8
Showing
30 changed files
with
508 additions
and
787 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import controllers, models | ||
from .hooks import post_init_hook | ||
from . import controllers | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import mail_blacklist | ||
from . import mail_mass_mailing | ||
from . import mail_mass_mailing_contact | ||
from . import mail_mass_mailing_list | ||
from . import mail_unsubscription |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Copyright 2019 Tecnativa - Ernesto Tejeda | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models | ||
|
||
|
||
class MailBlackList(models.Model): | ||
_inherit = 'mail.blacklist' | ||
|
||
def _add(self, email): | ||
mailing_id = self.env.context.get('mailing_id') | ||
res_id = self.env.context.get('unsubscription_res_id') | ||
if mailing_id and res_id: | ||
mailing = self.env['mail.mass_mailing'].browse(mailing_id, | ||
self._prefetch) | ||
model_name = mailing.mailing_model_real | ||
self.env["mail.unsubscription"].create({ | ||
"email": email, | ||
"mass_mailing_id": mailing_id, | ||
"unsubscriber_id": "%s,%d" % (model_name, res_id), | ||
"action": "blacklist_add", | ||
}) | ||
return super()._add(email) | ||
|
||
def _remove(self, email): | ||
mailing_id = self.env.context.get('mailing_id') | ||
res_id = self.env.context.get('unsubscription_res_id') | ||
if mailing_id and res_id: | ||
mailing = self.env['mail.mass_mailing'].browse(mailing_id, | ||
self._prefetch) | ||
model_name = mailing.mailing_model_real | ||
self.env["mail.unsubscription"].create({ | ||
"email": email, | ||
"mass_mailing_id": mailing_id, | ||
"unsubscriber_id": "%s,%d" % (model_name, res_id), | ||
"action": "blacklist_rm", | ||
}) | ||
return super()._remove(email) |
Oops, something went wrong.