Skip to content

Commit

Permalink
[UO-FIX] mass_mailing: rename columns in migration
Browse files Browse the repository at this point in the history
  • Loading branch information
MiquelRForgeFlow committed Mar 4, 2021
1 parent f93e3cc commit 2d9eb88
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ mass_mailing / mail.mass_mailing.list_contact_rel / list_id (many2one)
mass_mailing / mail.mass_mailing.list / contact_ids (many2many) : relation is now 'mailing.contact' ('mail.mass_mailing.contact') [nothing to do]
# NOTHING TO DO: Renamed models, but IDs don't change

mass_mailing / mail.mass_mailing / contact_list_ids (many2many) : column1 is now 'mailing_mailing_id' ('mail_mass_mailing_id')
mass_mailing / mail.mass_mailing / contact_list_ids (many2many) : column2 is now 'mailing_list_id' ('mail_mass_mailing_list_id')
# DONE: pre-migration: renamed columns

mass_mailing / link.tracker.click / mail_stat_id (many2one) : DEL relation: mail.mail.statistics
mass_mailing / link.tracker.click / mailing_trace_id (many2one) : NEW relation: mailing.trace
mass_mailing / mail.mail / mailing_trace_ids (one2many) : NEW relation: mailing.trace
Expand All @@ -65,6 +69,9 @@ mass_mailing / mail.mass_mailing.contact / tag_ids (many2many) : table
mass_mailing / mail.mass_mailing.list / contact_ids (many2many) : table is now 'mailing_contact_list_rel' ('mail_mass_mailing_contact_list_rel')
# DONE: pre-migration renamed tables

mass_mailing / mail.mass_mailing.contact / tag_ids (many2many) : column1 is now 'mailing_contact_id' ('mail_mass_mailing_contact_id')
# DONE: pre-migration: renamed column

mass_mailing / mail.mass_mailing.contact / website_message_ids (one2many): module is now 'portal' ('mass_mailing')
# NOTHING TO DO: Field relocated, but field definition XML-IDs are automatically handled by core

Expand Down
12 changes: 12 additions & 0 deletions addons/mass_mailing/migrations/13.0.2.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
# Copyright 2020 Payam Yasaie <https://www.tashilgostar.com>
# Copyright 2021 ForgeFlow <https://www.forgeflow.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade

_column_renames = {
'mail_mass_mailing_list_rel': [
('mail_mass_mailing_id', 'mailing_mailing_id'),
('mail_mass_mailing_list_id', 'mailing_list_id'),
],
'mail_mass_mailing_contact_res_partner_category_rel': [
('mail_mass_mailing_contact_id', 'mailing_contact_id'),
],
}

_model_renames = [
('mail.mail.statistics', 'mailing.trace'),
('mail.mass_mailing', 'mailing.mailing'),
Expand Down Expand Up @@ -63,6 +74,7 @@

@openupgrade.migrate()
def migrate(env, version):
openupgrade.rename_columns(env.cr, _column_renames)
openupgrade.rename_models(env.cr, _model_renames)
openupgrade.rename_tables(env.cr, _table_renames)
openupgrade.rename_fields(env, _field_renames)
Expand Down

0 comments on commit 2d9eb88

Please sign in to comment.