From 6675788d5b33a0175e7ba1535e10701dea6d51e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20-=20Le=20Filament?= <30716308+remi-filament@users.noreply.github.com> Date: Mon, 16 Sep 2024 11:59:40 +0200 Subject: [PATCH] [OU-ADD] product_email_template --- .../migrations/13.0.1.0/post-migration.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 addons/product_email_template/migrations/13.0.1.0/post-migration.py 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)