forked from OCA/OpenUpgrade
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c37220
commit 6675788
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
addons/product_email_template/migrations/13.0.1.0/post-migration.py
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,21 @@ | ||
# Copyright 2024 Le Filament <https://le-filament.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from openupgradelib import openupgrade | ||
|
||
|
||
def update_product_template_mail_model(env): | ||
""" | ||
Mail template model has changed from product.template to account.move in v13 | ||
""" | ||
account_move_model = env["ir.model"].search([("model", "=", "account.move")]) | ||
mail_template_ids = env["product.template"].search( | ||
[("email_template_id", "!=", False)] | ||
).mapped("email_template_id") | ||
mail_template_ids.filtered(lambda t: t.model=='product.template').write( | ||
{"model_id": account_move_model.id} | ||
) | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
update_product_template_mail_model(env) |