Skip to content

Commit

Permalink
Merge PR #4656 into 17.0
Browse files Browse the repository at this point in the history
Signed-off-by MiquelRForgeFlow
  • Loading branch information
OCA-git-bot committed Feb 4, 2025
2 parents 526961d + 31edde0 commit bb14d0a
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
2 changes: 2 additions & 0 deletions openupgrade_scripts/apriori.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
"l10n_es_irnr_sii": "l10n_es_aeat_sii_oca",
# OCA/purchase-workflow
"purchase_discount": "purchase",
# OCA/social
"mail_activity_plan": "mail",
# OCA/stock-logistics-warehouse
"stock_lot_filter_available": "stock",
# OCA/web
Expand Down
41 changes: 41 additions & 0 deletions openupgrade_scripts/scripts/mail/17.0.1.15/post-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,46 @@ def _mail_template_convert_report_template_m2o_to_m2m(env):
)


def _mail_activity_plan_template(env):
"""If the OCA mail_activity_plan module was installed, we create the
mail.activity.plan.template records.
"""
if not openupgrade.table_exists(env.cr, "mail_activity_plan_activity_type"):
return
openupgrade.logged_query(
env.cr,
"""
INSERT INTO mail_activity_plan_template (
plan_id,
sequence,
activity_type_id,
summary,
responsible_type,
responsible_id,
create_uid,
create_date,
write_uid,
write_date
) SELECT rel.mail_activity_plan_id,
10,
detail.activity_type_id,
detail.summary,
CASE
WHEN detail.user_id IS NOT NULL THEN 'other'
ELSE 'on_demand'
END AS responsible_type,
detail.user_id,
detail.create_uid,
detail.create_date,
detail.write_uid,
detail.write_date
FROM mail_activity_plan_mail_activity_plan_activity_type_rel AS rel
LEFT JOIN mail_activity_plan_activity_type AS detail
ON rel.mail_activity_plan_activity_type_id = detail.id
""",
)


@openupgrade.migrate()
def migrate(env, version):
openupgrade.load_data(env, "mail", "17.0.1.15/noupdate_changes.xml")
Expand All @@ -100,3 +140,4 @@ def migrate(env, version):
_fill_res_company_alias_domain_id(env)
_mail_alias_fill_alias_full_name(env)
_mail_template_convert_report_template_m2o_to_m2m(env)
_mail_activity_plan_template(env)
31 changes: 31 additions & 0 deletions openupgrade_scripts/scripts/mail/17.0.1.15/pre-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,36 @@ def _company_update_email_colors(env):
)


def _mail_activity_plan(env):
"""If the OCA mail_activity_plan module is installed, we convert the existing data
to adapt them to the standard.
"""
if not openupgrade.table_exists(env.cr, "mail_activity_plan"):
return
_mail_activity_plan_fields_renames = [
(
"mail.activity.plan",
"mail_activity_plan",
"model",
"res_model",
),
(
"mail.activity.plan",
"mail_activity_plan",
"model_id",
"res_model_id",
),
]
openupgrade.rename_fields(env, _mail_activity_plan_fields_renames)
openupgrade.remove_tables_fks(
env.cr,
[
"mail_activity_plan_activity_type",
"mail_activity_plan_mail_activity_plan_activity_type_rel",
],
)


@openupgrade.migrate()
def migrate(env, version):
openupgrade.rename_models(env.cr, _models_renames)
Expand All @@ -117,6 +147,7 @@ def migrate(env, version):
_mail_tracking_value_update_monetary_tracking_values(env)
_company_update_email_colors(env)
_mail_gateway_allowed(env)
_mail_activity_plan(env)
# create column to avoid model mail.alias is loaded before model res.company
openupgrade.logged_query(
env.cr,
Expand Down

0 comments on commit bb14d0a

Please sign in to comment.