-
-
Notifications
You must be signed in to change notification settings - Fork 700
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] mail: Refine migration scripts
- Loading branch information
1 parent
51ab4a3
commit 48b3f6b
Showing
4 changed files
with
44 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?xml version='1.0' encoding='utf-8'?> | ||
<odoo> | ||
<record id="base.partner_root" model="res.partner"> | ||
<!-- <record id="base.partner_root" model="res.partner"> | ||
<field name="email">[email protected]</field> | ||
<field name="image_1920" type="base64" file="mail/static/src/img/odoobot.png"/> | ||
<field name="name">OdooBot</field> | ||
|
@@ -10,5 +10,5 @@ | |
</record> | ||
<record id="module_install_notification" model="mail.message"> | ||
<field name="channel_ids" eval="[(4, ref('mail.channel_all_employees'))]"/> | ||
</record> | ||
</record> --> | ||
</odoo> |
20 changes: 3 additions & 17 deletions
20
openupgrade_scripts/scripts/mail/14.0.1.0/post-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 30 additions & 6 deletions
36
openupgrade_scripts/scripts/mail/14.0.1.0/pre-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,42 @@ | ||
# Copyright 2021 ForgeFlow S.L. <https://www.forgeflow.com> | ||
# Copyright 2021 Tecnativa - Pedro M. Baeza | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from openupgradelib import openupgrade | ||
|
||
|
||
def fill_mail_tracking_value_field(env): | ||
"""Now the field is a hard many2one reference, so we need to traverse the | ||
ir.model.fields record and fill it. | ||
As the column is required, we do it on pre, and we need also to remove those | ||
records whose field reference doesn't exist anymore. | ||
""" | ||
openupgrade.logged_query(env.cr, "ALTER TABLE mail_tracking_value ADD field int4") | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
UPDATE mail_tracking_value mtv | ||
SET field = imf.id | ||
FROM ir_model_fields imf | ||
JOIN mail_message mm ON imf.model = mm.model | ||
WHERE imf.name = mtv.{} AND mtv.mail_message_id = mm.id | ||
""".format( | ||
openupgrade.get_legacy_name("field") | ||
), | ||
) | ||
openupgrade.logged_query( | ||
env.cr, "DELETE FROM mail_tracking_value WHERE field IS NULL" | ||
) | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
openupgrade.rename_models( | ||
env.cr, [("email_template.preview", "mail.template.preview")] | ||
) | ||
openupgrade.set_xml_ids_noupdate_value(env, "mail", ["mail_channel_rule"], True) | ||
openupgrade.update_module_moved_fields( | ||
env.cr, "mail.mail", ["description"], "website_mail", "mail" | ||
) | ||
openupgrade.update_module_moved_fields( | ||
env.cr, "mail.message", ["description"], "website_mail", "mail" | ||
openupgrade.rename_tables( | ||
env.cr, [("email_template_preview", "mail_template_preview")] | ||
) | ||
openupgrade.set_xml_ids_noupdate_value(env, "mail", ["mail_channel_rule"], True) | ||
openupgrade.rename_columns(env.cr, {"mail_tracking_value": [("field", None)]}) | ||
fill_mail_tracking_value_field(env) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters