Skip to content

Commit

Permalink
[ADD] add cooperator 14.0.1.0.0 migration script
Browse files Browse the repository at this point in the history
  • Loading branch information
huguesdk committed May 17, 2024
1 parent e9d1397 commit debfff9
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions cooperator/migrations/14.0.1.0.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit debfff9

Please sign in to comment.