forked from OCA/social
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhooks.py
23 lines (17 loc) · 884 Bytes
/
hooks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Copyright 2021 Camptocamp (https://www.camptocamp.com).
# @author Iván Todorovich <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import SUPERUSER_ID, api
def _apply_default_mailing_list_values(env):
"""Apply default mailing.list values to existing records
When the field is created by the ORM, the new mail.template records don't exist yet,
so their values aren't set.
"""
module = "mass_mailing_subscription_email"
records = env["mailing.list"].search([])
records.subscribe_template_id = env.ref(f"{module}.mailing_list_subscribe")
records.unsubscribe_template_id = env.ref(f"{module}.mailing_list_unsubscribe")
def post_init_hook(cr, registry):
with api.Environment.manage():
env = api.Environment(cr, SUPERUSER_ID, {})
_apply_default_mailing_list_values(env)