diff --git a/openupgrade_scripts/scripts/mail/17.0.1.15/noupdate_changes.xml b/openupgrade_scripts/scripts/mail/17.0.1.15/noupdate_changes.xml
index 6e70d7dcd7e2..8b63a9277e23 100644
--- a/openupgrade_scripts/scripts/mail/17.0.1.15/noupdate_changes.xml
+++ b/openupgrade_scripts/scripts/mail/17.0.1.15/noupdate_changes.xml
@@ -7,7 +7,7 @@
['|', ('create_uid', '=', user.id), ('user_id', '=', user.id)]
Employees can only modify templates they have created or been assigned
-
+
diff --git a/openupgrade_scripts/scripts/mail/17.0.1.15/post-migration.py b/openupgrade_scripts/scripts/mail/17.0.1.15/post-migration.py
index e427cf2e4436..bd227998871d 100644
--- a/openupgrade_scripts/scripts/mail/17.0.1.15/post-migration.py
+++ b/openupgrade_scripts/scripts/mail/17.0.1.15/post-migration.py
@@ -13,12 +13,23 @@
]
+def _discuss_channel_fill_allow_public_upload(env):
+ openupgrade.logged_query(
+ env.cr,
+ """
+ UPDATE discuss_channel
+ SET allow_public_upload = True
+ WHERE channel_type = 'livechat'
+ """,
+ )
+
+
def _fill_res_company_alias_domain_id(env):
icp = env["ir.config_parameter"]
domain = icp.get_param("mail.catchall.domain")
if domain:
- alias_domain_id = openupgrade.logged_query(
+ openupgrade.logged_query(
env.cr,
f"""
INSERT INTO mail_alias_domain (
@@ -32,6 +43,7 @@ def _fill_res_company_alias_domain_id(env):
RETURNING id;
""",
)
+ (alias_domain_id,) = env.cr.fetchone()
openupgrade.logged_query(
env.cr,
f"""
@@ -51,32 +63,20 @@ def _fill_res_company_alias_domain_id(env):
def _mail_alias_fill_alias_full_name(env):
- # Because we fill same alias domain for every company so only need one here
- company = env["res.company"].search([], limit=1)
- if company.alias_domain_id:
- openupgrade.logged_query(
- env.cr,
- f"""
- UPDATE mail_alias
- SET alias_domain_id = {company.alias_domain_id.id},
- alias_full_name = CASE
- WHEN alias_name IS NOT NULL
- THEN alias_name || '@' || '{company.alias_domain_id.name}'
- ELSE NULL
- END
- """,
- )
- else:
- openupgrade.logged_query(
- env.cr,
- """
- UPDATE mail_alias
- SET alias_full_name = CASE
- WHEN alias_name IS NOT NULL THEN alias_name
- ELSE NULL
- END
- """,
- )
+ openupgrade.logged_query(
+ env.cr,
+ """
+ UPDATE mail_alias
+ SET
+ alias_domain_id = mail_alias_domain.id,
+ alias_full_name = CASE
+ WHEN alias_name IS NOT NULL
+ THEN alias_name || '@' || mail_alias_domain.name
+ ELSE NULL
+ END
+ FROM mail_alias_domain
+ """,
+ )
def _mail_template_convert_report_template_m2o_to_m2m(env):
@@ -96,6 +96,7 @@ def migrate(env, version):
env,
_deleted_xml_records,
)
+ _discuss_channel_fill_allow_public_upload(env)
_fill_res_company_alias_domain_id(env)
_mail_alias_fill_alias_full_name(env)
_mail_template_convert_report_template_m2o_to_m2m(env)
diff --git a/openupgrade_scripts/scripts/mail/17.0.1.15/pre-migration.py b/openupgrade_scripts/scripts/mail/17.0.1.15/pre-migration.py
index 8a4d181b97b5..317b10c2dec8 100644
--- a/openupgrade_scripts/scripts/mail/17.0.1.15/pre-migration.py
+++ b/openupgrade_scripts/scripts/mail/17.0.1.15/pre-migration.py
@@ -11,33 +11,26 @@
("mail_channel", "discuss_channel"),
("mail_channel_member", "discuss_channel_member"),
("mail_channel_rtc_session", "discuss_channel_rtc_session"),
+ ("mail_channel_res_groups_rel", "discuss_channel_res_groups_rel"),
]
_fields_renames = [
(
- "discuss.channel",
- "discuss_channel",
+ "mail.tracking.value",
+ "mail_tracking_value",
"field",
"field_id",
),
]
-
-
-def _discuss_channel_fill_allow_public_upload(env):
- openupgrade.logged_query(
- env.cr,
- """
- ALTER TABLE discuss_channel
- ADD COLUMN IF NOT EXISTS allow_public_upload BOOLEAN;
- """,
- )
- openupgrade.logged_query(
- env.cr,
- """
- UPDATE discuss_channel
- SET allow_public_upload = True
- WHERE channel_type = 'livechat'
- """,
- )
+_columns_renames = {
+ "discuss_channel_res_groups_rel": [
+ ("mail_channel_id", "discuss_channel_id"),
+ ],
+}
+_columns_copies = {
+ "mail_template": [
+ ("report_template", None, None),
+ ],
+}
def _mail_alias_fill_multiple_values(env):
@@ -58,14 +51,9 @@ def _mail_alias_fill_multiple_values(env):
env.cr,
"""
UPDATE mail_alias
- SET alias_incoming_local = True
- """,
- )
- openupgrade.logged_query(
- env.cr,
- """
- UPDATE mail_alias
- SET alias_status = 'not_tested'
+ SET
+ alias_incoming_local = True,
+ alias_status = 'valid'
""",
)
@@ -83,6 +71,16 @@ def _mail_tracking_value_update_monetary_tracking_values(env):
)
+def _mail_gateway_allowed(env):
+ """Set some dummy value so that the not null constraint can be created"""
+ env.cr.execute(
+ """
+ UPDATE mail_gateway_allowed SET email='admin@example.com'
+ WHERE email IS NULL
+ """
+ )
+
+
def _company_update_email_colors(env):
openupgrade.logged_query(
env.cr,
@@ -113,10 +111,12 @@ def migrate(env, version):
openupgrade.rename_models(env.cr, _models_renames)
openupgrade.rename_tables(env.cr, _tables_renames)
openupgrade.rename_fields(env, _fields_renames)
- _discuss_channel_fill_allow_public_upload(env)
+ openupgrade.rename_columns(env.cr, _columns_renames)
+ openupgrade.copy_columns(env.cr, _columns_copies)
_mail_alias_fill_multiple_values(env)
_mail_tracking_value_update_monetary_tracking_values(env)
_company_update_email_colors(env)
+ _mail_gateway_allowed(env)
# create column to avoid model mail.alias is loaded before model res.company
openupgrade.logged_query(
env.cr,
diff --git a/openupgrade_scripts/scripts/mail/17.0.1.15/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/mail/17.0.1.15/upgrade_analysis_work.txt
index d93ad6f51800..36172526b692 100644
--- a/openupgrade_scripts/scripts/mail/17.0.1.15/upgrade_analysis_work.txt
+++ b/openupgrade_scripts/scripts/mail/17.0.1.15/upgrade_analysis_work.txt
@@ -1,26 +1,22 @@
---Models in module 'mail'---
obsolete model mail.channel
-# DONE: renamed to discuss.channel in pre-migration
+new model discuss.channel
+# DONE: pre-migration: Renamed
obsolete model mail.channel.member
-# DONE: renamed to discuss.channel.member in pre-migration
+new model discuss.channel.member
+# DONE: pre-migration: Renamed
obsolete model mail.channel.rtc.session
-# DONE: renamed to discuss.channel.rtc.session in pre-migration
+new model discuss.channel.rtc.session
+# DONE: pre-migration: Renamed
model res.users.settings (moved to base)
-new model discuss.channel
-# DONE: renamed from mail.channel in pre-migration
-
-new model discuss.channel.member
-# DONE: renamed from mail.channel.member in pre-migration
-
-new model discuss.channel.rtc.session
-# DONE: renamed from mail.channel.rtc.session in pre-migration
+# NOTHING TO DO: Done on `base`
new model discuss.gif.favorite
new model discuss.voice.metadata
-# NOTHING TO DO: new feature
+# NOTHING TO DO: new features
new model mail.activity.plan
new model mail.activity.plan.template
@@ -31,7 +27,7 @@ new model mail.activity.schedule [transient]
new model mail.alias.domain
new model mail.alias.mixin.optional [abstract]
-# DONE: create new record from ir.config_parameter and fill in post-migration
+# DONE: post-migration: create new record from ir.config_parameter and fill
new model mail.thread.main.attachment [abstract]
# NOTHING TO DO: split from mail.thread
@@ -43,68 +39,20 @@ new model mail.tracking.duration.mixin [abstract]
# NOTHING TO DO: new feature
---Fields in module 'mail'---
-mail / discuss.channel / active (boolean) : NEW hasdefault: default
-# NOTHING TO DO: renamed model
-
mail / discuss.channel / allow_public_upload (boolean) : NEW hasdefault: default
-# DONE pre-migration: set True for channel_type = 'livechat' because customer need to upload some documents
-
-mail / discuss.channel / channel_member_ids (one2many) : NEW relation: discuss.channel.member
-mail / discuss.channel / channel_type (selection) : NEW required, selection_keys: ['channel', 'chat', 'group']
-mail / discuss.channel / default_display_mode (selection): NEW selection_keys: ['video_full_screen']
-mail / discuss.channel / description (text) : NEW
-mail / discuss.channel / group_ids (many2many) : NEW relation: res.groups
-mail / discuss.channel / group_public_id (many2one) : NEW relation: res.groups, hasdefault: compute
-mail / discuss.channel / image_128 (binary) : NEW attachment: True
-mail / discuss.channel / message_follower_ids (one2many): NEW relation: mail.followers
-mail / discuss.channel / message_ids (one2many) : NEW relation: mail.message
-mail / discuss.channel / name (char) : NEW required
-# NOTHING TO DO: renamed model
+# DONE: post-migration: set True for channel_type = 'livechat' because customer need to upload some documents
mail / discuss.channel / pinned_message_ids (one2many) : NEW relation: mail.message
# NOTHING TO DO: new feature to pin message
-mail / discuss.channel / rtc_session_ids (one2many) : NEW relation: discuss.channel.rtc.session
-# NOTHING TO DO: renamed model
-
mail / discuss.channel / sfu_channel_uuid (char) : NEW
mail / discuss.channel / sfu_server_url (char) : NEW
# NOTHING TO DO: new feature
-mail / discuss.channel / uuid (char) : NEW hasdefault: default
-# NOTHING TO DO: renamed model
-
-mail / discuss.channel.member / channel_id (many2one) : NEW relation: discuss.channel, required
-mail / discuss.channel.member / custom_channel_name (char) : NEW
-# NOTHING TO DO: renamed model
-
mail / discuss.channel.member / custom_notifications (selection): NEW selection_keys: ['mentions', 'no_notif']
mail / discuss.channel.member / mute_until_dt (datetime) : NEW
# NOTHING TO DO: new feature
-mail / discuss.channel.member / fetched_message_id (many2one) : NEW relation: mail.message
-mail / discuss.channel.member / fold_state (selection) : NEW selection_keys: ['closed', 'folded', 'open'], hasdefault: default
-mail / discuss.channel.member / guest_id (many2one) : NEW relation: mail.guest
-mail / discuss.channel.member / is_minimized (boolean) : NEW
-mail / discuss.channel.member / is_pinned (boolean) : NEW hasdefault: default
-mail / discuss.channel.member / last_interest_dt (datetime) : NEW hasdefault: default
-mail / discuss.channel.member / last_seen_dt (datetime) : NEW
-# NOTHING TO DO: renamed model
-
-mail / discuss.channel.member / partner_id (many2one) : NEW relation: res.partner
-mail / discuss.channel.member / rtc_inviting_session_id (many2one): NEW relation: discuss.channel.rtc.session
-mail / discuss.channel.member / rtc_session_ids (one2many) : NEW relation: discuss.channel.rtc.session
-mail / discuss.channel.member / seen_message_id (many2one) : NEW relation: mail.message
-# NOTHING TO DO: renamed model
-
-mail / discuss.channel.rtc.session / channel_id (many2one) : NEW relation: discuss.channel, isrelated: related, stored
-mail / discuss.channel.rtc.session / channel_member_id (many2one) : NEW relation: discuss.channel.member, required
-mail / discuss.channel.rtc.session / is_camera_on (boolean) : NEW
-mail / discuss.channel.rtc.session / is_deaf (boolean) : NEW
-mail / discuss.channel.rtc.session / is_muted (boolean) : NEW
-mail / discuss.channel.rtc.session / is_screen_sharing_on (boolean): NEW
-# NOTHING TO DO: renamed model
-
mail / discuss.gif.favorite / tenor_gif_id (char) : NEW required
mail / discuss.voice.metadata / attachment_id (many2one) : NEW relation: ir.attachment
mail / ir.actions.act_window.view / view_mode (False) : selection_keys is now '['activity', 'calendar', 'form', 'gantt', 'graph', 'hierarchy', 'kanban', 'pivot', 'tree']' ('['activity', 'calendar', 'form', 'gantt', 'graph', 'kanban', 'pivot', 'qweb', 'tree']')
@@ -131,16 +79,17 @@ mail / mail.activity.plan.template / responsible_type (selection) : NEW
mail / mail.activity.plan.template / sequence (integer) : NEW hasdefault: default
mail / mail.activity.plan.template / summary (char) : NEW hasdefault: compute
mail / mail.activity.type / keep_done (boolean) : NEW
-# NOTHING TO DO: new feature
+# NOTHING TO DO: new feature like the existing OCA module https://github.com/OCA/social/tree/16.0/mail_activity_plan
mail / mail.alias / alias_full_name (char) : NEW isfunction: function, stored
-# DONE pre and post migration: create column in pre and fill value in post
+# DONE: pre-migration: create column
+# DONE: post-migration: fill value
mail / mail.alias / alias_incoming_local (boolean): NEW hasdefault: default
-# DONE pre-migration: create column and set to True following to commit https://github.com/odoo/odoo/pull/76734/commits/b1a3613ffca3b79304a4c7b9aad05d76a7113460
+# DONE: pre-migration: create column and set to True following to commit https://github.com/odoo/odoo/pull/76734/commits/b1a3613ffca3b79304a4c7b9aad05d76a7113460
mail / mail.alias / alias_status (selection) : NEW selection_keys: ['invalid', 'not_tested', 'valid'], isfunction: function, stored
-# DONE pre-migration: create column and set to 'not_tested' (it will set to 'valid' later when message has been processed)
+# DONE: pre-migration: create column and set to 'not_tested' (it will set to 'valid' later when message has been processed)
mail / mail.alias / alias_user_id (many2one) : DEL relation: res.users
# NOTHING TO DO: following https://github.com/odoo/odoo/pull/138213
@@ -148,41 +97,6 @@ mail / mail.alias / alias_user_id (many2one) : DEL re
mail / mail.blacklist / message_main_attachment_id (many2one): DEL relation: ir.attachment
# NOTHING TO DO
-mail / mail.channel / active (boolean) : DEL
-mail / mail.channel / channel_member_ids (one2many) : DEL relation: mail.channel.member
-mail / mail.channel / channel_type (selection) : DEL required, selection_keys: ['channel', 'chat', 'group']
-mail / mail.channel / default_display_mode (selection): DEL selection_keys: ['video_full_screen']
-mail / mail.channel / description (text) : DEL
-mail / mail.channel / group_ids (many2many) : DEL relation: res.groups
-mail / mail.channel / group_public_id (many2one) : DEL relation: res.groups
-mail / mail.channel / image_128 (binary) : DEL attachment: True
-mail / mail.channel / message_follower_ids (one2many): DEL relation: mail.followers
-mail / mail.channel / message_ids (one2many) : DEL relation: mail.message
-mail / mail.channel / message_main_attachment_id (many2one): DEL relation: ir.attachment
-mail / mail.channel / name (char) : DEL required
-mail / mail.channel / rtc_session_ids (one2many) : DEL relation: mail.channel.rtc.session
-mail / mail.channel / uuid (char) : DEL
-mail / mail.channel.member / channel_id (many2one) : DEL relation: mail.channel, required
-mail / mail.channel.member / custom_channel_name (char) : DEL
-mail / mail.channel.member / fetched_message_id (many2one) : DEL relation: mail.message
-mail / mail.channel.member / fold_state (selection) : DEL selection_keys: ['closed', 'folded', 'open']
-mail / mail.channel.member / guest_id (many2one) : DEL relation: mail.guest
-mail / mail.channel.member / is_minimized (boolean) : DEL
-mail / mail.channel.member / is_pinned (boolean) : DEL
-mail / mail.channel.member / last_interest_dt (datetime) : DEL
-mail / mail.channel.member / last_seen_dt (datetime) : DEL
-mail / mail.channel.member / partner_id (many2one) : DEL relation: res.partner
-mail / mail.channel.member / rtc_inviting_session_id (many2one): DEL relation: mail.channel.rtc.session
-mail / mail.channel.member / rtc_session_ids (one2many) : DEL relation: mail.channel.rtc.session
-mail / mail.channel.member / seen_message_id (many2one) : DEL relation: mail.message
-mail / mail.channel.rtc.session / channel_id (many2one) : DEL relation: mail.channel
-mail / mail.channel.rtc.session / channel_member_id (many2one) : DEL relation: mail.channel.member, required
-mail / mail.channel.rtc.session / is_camera_on (boolean) : DEL
-mail / mail.channel.rtc.session / is_deaf (boolean) : DEL
-mail / mail.channel.rtc.session / is_muted (boolean) : DEL
-mail / mail.channel.rtc.session / is_screen_sharing_on (boolean): DEL
-# NOTHING TO DO: renamed model
-
mail / mail.gateway.allowed / email (char) : now required
# DONE pre-migration: fill dummy value if Null found
@@ -190,7 +104,7 @@ mail / mail.guest / channel_ids (many2many) : relati
# NOTHING TO DO
mail / mail.guest / channel_ids (many2many) : table is now 'discuss_channel_member' ('mail_channel_member')
-# DONE pre-migration: rename table
+# DONE: pre-migration: rename table
mail / mail.link.preview / og_site_name (char) : NEW
# NOTHING TO DO: if it really need to be fill, just loop through the mail.link.preview records that either not image or video and use 'get_link_preview_from_html'
@@ -247,7 +161,7 @@ mail / mail.template / report_name (char) : DEL
mail / mail.template / report_template (many2one) : DEL relation: ir.actions.report
mail / mail.template / report_template_ids (many2many): NEW relation: ir.actions.report
-# DONE pre-migraton: m2o to m2m
+# DONE post-migraton: m2o to m2m
mail / mail.template / user_id (many2one) : NEW relation: res.users
# NOTHING TO DO: new feature
@@ -261,11 +175,11 @@ mail / mail.tracking.value / tracking_sequence (integer) : DEL
mail / mail.tracking.value / field (many2one) : DEL relation: ir.model.fields, required
mail / mail.tracking.value / field_id (many2one) : NEW relation: ir.model.fields
-# DONE pre-migration: rename field
+# DONE: pre-migration: rename field
mail / mail.tracking.value / new_value_monetary (float) : DEL
mail / mail.tracking.value / old_value_monetary (float) : DEL
-# TODO pre-migration: fill value into old/new_value_float
+# DONE: pre-migration: fill value into old/new_value_float
mail / mail.alias.domain / bounce_alias (char) : NEW required, hasdefault: default
mail / mail.alias.domain / catchall_alias (char) : NEW required, hasdefault: default
@@ -278,11 +192,11 @@ mail / mail.alias / alias_domain (char) : now re
mail / mail.alias / alias_domain_id (many2one) : NEW relation: mail.alias.domain, hasdefault: default
mail / res.company / alias_domain_id (many2one) : NEW relation: mail.alias.domain, hasdefault: default
mail / res.company / alias_domain_name (char) : NEW isrelated: related, stored
-# DONE: create new record from ir.config_parameter and fill in post-migration
+# DONE: post-migration: create new record from ir.config_parameter and fill it
mail / res.company / email_primary_color (char) : NEW hasdefault: compute
mail / res.company / email_secondary_color (char) : NEW hasdefault: compute
-# DONE pre-migration: update these field according to company primary and secondary color
+# DONE: pre-migration: update these field according to company primary and secondary color
mail / res.partner / activity_user_id (many2one) : not related anymore
mail / res.partner / activity_user_id (many2one) : now a function
@@ -298,7 +212,7 @@ mail / res.users / res_users_settings_ids (one2many): mod
mail / res.users.settings / _order : module is now 'base' ('mail')
mail / res.users.settings / display_name (char) : module is now 'base' ('mail')
mail / res.users.settings / user_id (many2one) : module is now 'base' ('mail')
-# NOTHING TODO
+# NOTHING TO DO: done in base migration scripts
---XML records in module 'mail'---
NEW discuss.channel: mail.channel_all_employees (noupdate)
@@ -408,7 +322,7 @@ DEL ir.rule: mail.ir_rule_mail_channel_member_group_system (noupdate)
DEL ir.rule: mail.ir_rule_mail_channel_member_group_user (noupdate)
DEL ir.rule: mail.mail_channel_admin (noupdate)
DEL ir.rule: mail.mail_channel_rule (noupdate)
-# NOTHING TO DO: removed in post-migration
+# DONE: post-migration: safe removal
DEL ir.rule: mail.res_users_settings_rule_admin [renamed to base module] (noupdate)
DEL ir.rule: mail.res_users_settings_rule_user [renamed to base module] (noupdate)
@@ -482,7 +396,7 @@ DEL ir.ui.view: mail.view_mail_alias_tree
DEL mail.channel: mail.channel_all_employees (noupdate)
DEL mail.channel.member: mail.channel_member_general_channel_for_admin (noupdate)
-# NOTHING TO DO: removed in post-migration
+# DONE: post-migration: safe removal
NEW res.groups: mail.group_mail_notification_type_inbox (noupdate)
# NOTHING TO DO