-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '12.0-mail-template-migration' into 12.0-openupgrade
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Copyright 2022 Coop IT Easy SCRLfs | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
import logging | ||
|
||
from openupgradelib import openupgrade | ||
|
||
logger = logging.getLogger("OpenUpgrade") | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
# Set all values 'easy_my_coop' to True for mail templates belonging to the | ||
# easy_my_coop% modules. (T2772) | ||
domain = [("model", "=", "mail.template"), ("module", "=like", "easy_my_coop%")] | ||
model_data = env["ir.model.data"].search(domain) | ||
templates = env["mail.template"].browse([md.res_id for md in model_data]) | ||
model_data_by_res_id = {md.res_id: md for md in model_data} | ||
for entry in templates: | ||
if not entry.easy_my_coop: | ||
md = model_data_by_res_id[entry.id] | ||
logger.info( | ||
"Changing field 'easy_my_coop' from False to True in '{}'".format( | ||
"{}.{}".format(md.module, md.name) | ||
) | ||
) | ||
entry.easy_my_coop = True |