Skip to content

Commit

Permalink
Merge branch '12.0-mail-template-migration' into 12.0-openupgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
huguesdk committed May 13, 2022
2 parents 4361523 + 2f353a7 commit 805886d
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions easy_my_coop/migrations/12.0.3.3.1/end-migration.py
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

0 comments on commit 805886d

Please sign in to comment.