From debfff9aacad4d7884fc02bf95dd0897e6229b0b Mon Sep 17 00:00:00 2001 From: hugues de keyzer Date: Tue, 16 Aug 2022 22:24:43 +0200 Subject: [PATCH] [ADD] add cooperator 14.0.1.0.0 migration script --- .../migrations/14.0.1.0.0/post-migration.py | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 cooperator/migrations/14.0.1.0.0/post-migration.py diff --git a/cooperator/migrations/14.0.1.0.0/post-migration.py b/cooperator/migrations/14.0.1.0.0/post-migration.py new file mode 100644 index 000000000..d4001611d --- /dev/null +++ b/cooperator/migrations/14.0.1.0.0/post-migration.py @@ -0,0 +1,46 @@ +# Copyright 2022 Coop IT Easy SC +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openupgradelib import openupgrade + + +MAIL_TEMPLATES = [ + "email_template_release_capital", + "email_template_confirmation", + "email_template_waiting_list", + "email_template_confirmation_company", + "email_template_certificat", + "email_template_certificat_increase", + "email_template_share_transfer", + "email_template_share_update", +] + + +def fill_account_move_columns(env): + openupgrade.logged_query( + env.cr, + """ + update account_move as am + set subscription_request = ai.subscription_request, + release_capital_request = ai.release_capital_request + from account_invoice as ai + where am.old_invoice_id = ai.id + """, + ) + + +def reload_mail_templates(env): + # force reload of mail templates, since they are marked as noupdate. it + # would be possible to reload only what has changed, but there are too + # many changes, so it is easier to reload everything. warning: any change + # made to these will be lost. + openupgrade.load_data(env.cr, "cooperator", "data/mail_template_data.xml") + # delete the translations so that they can be updated (because the records + # are marked as noupdate). + openupgrade.delete_record_translations(env.cr, "cooperator", MAIL_TEMPLATES) + + +@openupgrade.migrate() +def migrate(env, version): + fill_account_move_columns(env) + reload_mail_templates(env)