Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][OU-ADD] mail_activity_plan: Merged into mail #4656

Open
wants to merge 1 commit into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions openupgrade_scripts/apriori.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
"l10n_es_irnr_sii": "l10n_es_aeat_sii_oca",
# OCA/purchase-workflow
"purchase_discount": "purchase",
# OCA/social
"mail_activity_plan": "mail",
# OCA/web
"web_advanced_search": "web",
"web_listview_range_select": "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(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(env)
24 changes: 24 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,29 @@ 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.migrate()
def migrate(env, version):
openupgrade.rename_models(env.cr, _models_renames)
Expand All @@ -117,6 +140,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
Loading