diff --git a/addons/product_email_template/migrations/13.0.1.0/post-migration.py b/addons/product_email_template/migrations/13.0.1.0/post-migration.py new file mode 100644 index 000000000000..99612b15c35b --- /dev/null +++ b/addons/product_email_template/migrations/13.0.1.0/post-migration.py @@ -0,0 +1,21 @@ +# Copyright 2024 Le Filament +# 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)