From c0c61ee63437531b2a62de54ea58ea23cdafb8e1 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Tue, 28 Oct 2014 13:13:28 +0100 Subject: [PATCH 1/4] [ADD] [8.0] 'mail' migration; --- .../8.0.1.0/openupgrade_analysis_work.txt | 48 +++++++++++++ .../mail/migrations/8.0.1.0/post-migration.py | 69 +++++++++++++++++++ .../mail/migrations/8.0.1.0/pre-migration.py | 41 +++++++++++ 3 files changed, 158 insertions(+) create mode 100644 addons/mail/migrations/8.0.1.0/openupgrade_analysis_work.txt create mode 100644 addons/mail/migrations/8.0.1.0/post-migration.py create mode 100644 addons/mail/migrations/8.0.1.0/pre-migration.py diff --git a/addons/mail/migrations/8.0.1.0/openupgrade_analysis_work.txt b/addons/mail/migrations/8.0.1.0/openupgrade_analysis_work.txt new file mode 100644 index 000000000000..b76b90b1ddcd --- /dev/null +++ b/addons/mail/migrations/8.0.1.0/openupgrade_analysis_work.txt @@ -0,0 +1,48 @@ +---Fields in module 'mail'--- +mail / mail.alias / alias_contact (selection) : NEW required: required, selection_keys: ['everyone', 'followers', 'partners'], req_default: everyone +mail / mail.alias / alias_parent_model_id (many2one): NEW relation: ir.model +mail / mail.alias / alias_parent_thread_id (integer): NEW +mail / mail.mail / recipient_ids (many2many) : NEW relation: res.partner +mail / mail.message / record_name (char) : not a function anymore +mail / mail.message.subtype / hidden (boolean) : NEW +mail / mail.message.subtype / sequence (integer) : NEW +# Nothing to do + +mail / mail.group / message_last_post (datetime) : NEW +# Done + +mail / mail.mail / email_from (char) : DEL +mail / mail.mail / mail_server_id (many2one) : DEL relation: ir.mail_server +mail / mail.message / mail_server_id (many2one) : NEW relation: ir.mail_server +mail / mail.mail / reply_to (char) : DEL +mail / mail.message / reply_to (char) : NEW +# Moved from mail.mail to mail.message + +mail / mail.thread / message_follower_ids (many2many): module is now 'website_mail' ('mail') +mail / mail.thread / message_ids (one2many) : module is now 'website_mail' ('mail') +mail / mail.thread / message_is_follower (boolean) : module is now 'website_mail' ('mail') +mail / mail.thread / message_summary (text) : module is now 'website_mail' ('mail') +mail / mail.thread / message_unread (boolean) : module is now 'website_mail' ('mail') +# Calculated functional fields, nothing to do. + +mail / res.partner / message_last_post (datetime) : NEW +# Done + +mail / res.partner / notification_email_send (selection): selection_keys is now '['always', 'none']' ('['all', 'comment', 'email', 'none']') +mail / res.partner / notification_email_send (selection): was renamed to notify_email [nothing to to] +# Done + +mail / res.users / display_groups_suggestions (boolean): NEW +# Set defaults: Done + +---XML records in module 'mail'--- +NEW ir.actions.act_window: base.action_attachment +NEW ir.actions.client: mail.action_client_messaging_menu +NEW ir.actions.server: mail.action_mail_redirect +NEW ir.actions.todo: base.open_menu +NEW ir.config_parameter: mail.icp_mail_catchall_alias +NEW ir.rule: mail.mail_followers_read_write_others +NEW ir.ui.view: mail.assets_backend +NEW ir.ui.view: mail.view_document_file_kanban +NEW res.partner: base.partner_root +# Nothing to do \ No newline at end of file diff --git a/addons/mail/migrations/8.0.1.0/post-migration.py b/addons/mail/migrations/8.0.1.0/post-migration.py new file mode 100644 index 000000000000..bb99f2820d08 --- /dev/null +++ b/addons/mail/migrations/8.0.1.0/post-migration.py @@ -0,0 +1,69 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2010 - 2014 Savoir-faire Linux +# (). +# (). +# @author: Onestein +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + + +from openerp import pooler, SUPERUSER_ID as uid +from openerp.openupgrade import openupgrade, openupgrade_80 + +default_spec = { + 'res.users': [ + ('display_groups_suggestions', True), + ], +} + + +def mail_mail_to_mail_message_migration(cr, uid, pool): + """ + The following fields have been moved from mail.mail to mail.message + * mail_server_id + * reply_to + Get the mail.message from the mail.mail object and transfer the data that + way. + """ + legacy_server_id = openupgrade.get_legacy_name('mail_server_id') + legacy_reply_to = openupgrade.get_legacy_name('reply_to') + openupgrade.logged_query(cr, """ +UPDATE mail_message +SET %s = %s, %s = %s +FROM mail_message AS a JOIN mail_mail AS b ON a.id = b.mail_message_id +""" % ('mail_server_id', legacy_server_id, 'reply_to', legacy_reply_to, )) + + +def map_notify_email(cr): + openupgrade.map_values( + cr, + 'notify_email', + 'notify_email', + [('all', 'always'), ('comment', 'always'), ('email', 'always'), ('none', 'none')], + table='res_partner', write='sql') + + +@openupgrade.migrate() +def migrate(cr, version): + pool = pooler.get_pool(cr.dbname) + + map_notify_email(cr) + mail_mail_to_mail_message_migration(cr, uid, pool) + openupgrade_80.set_message_last_post(cr, uid, pool, ['res.partner', 'mail.group']) + openupgrade.set_defaults(cr, pool, default_spec, force=False) diff --git a/addons/mail/migrations/8.0.1.0/pre-migration.py b/addons/mail/migrations/8.0.1.0/pre-migration.py new file mode 100644 index 000000000000..ec0e3b3b16e6 --- /dev/null +++ b/addons/mail/migrations/8.0.1.0/pre-migration.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2014 Akretion (http://www.akretion.com/) +# @author: Alexis de Lattre +# (). +# @author: Onestein +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.openupgrade import openupgrade + +column_renames = { + 'res_partner': [ + ('notification_email_send', 'notify_email'), + ], + 'mail_mail': [ + ('email_from', None), + + ('mail_server_id', None), + ('reply_to', None), + ] +} + + +@openupgrade.migrate() +def migrate(cr, version): + openupgrade.rename_columns(cr, column_renames) From f1632074c74eff0a50180d0571cd6143433e8e6d Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Fri, 28 Nov 2014 11:51:35 +0100 Subject: [PATCH 2/4] [ADD] update aliases for mail.group and res.users --- addons/mail/migrations/8.0.1.0/post-migration.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/mail/migrations/8.0.1.0/post-migration.py b/addons/mail/migrations/8.0.1.0/post-migration.py index bb99f2820d08..6dec5da5639a 100644 --- a/addons/mail/migrations/8.0.1.0/post-migration.py +++ b/addons/mail/migrations/8.0.1.0/post-migration.py @@ -67,3 +67,5 @@ def migrate(cr, version): mail_mail_to_mail_message_migration(cr, uid, pool) openupgrade_80.set_message_last_post(cr, uid, pool, ['res.partner', 'mail.group']) openupgrade.set_defaults(cr, pool, default_spec, force=False) + openupgrade_80.update_aliases(cr, pool, 'mail.group', True) + openupgrade_80.update_aliases(cr, pool, 'res.users', True) From 47ba3f93c6f31c806369be9247ad0736bb96cc56 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Fri, 28 Nov 2014 14:16:27 +0100 Subject: [PATCH 3/4] [IMP] update module coverage table --- openerp/openupgrade/doc/source/modules70-80.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openerp/openupgrade/doc/source/modules70-80.rst b/openerp/openupgrade/doc/source/modules70-80.rst index 35f99178b2a0..737247907e13 100644 --- a/openerp/openupgrade/doc/source/modules70-80.rst +++ b/openerp/openupgrade/doc/source/modules70-80.rst @@ -286,7 +286,7 @@ Status : +-----------------------------------+-----------------------------------+ |lunch | Nothing to do | +-----------------------------------+-----------------------------------+ -|mail | | +|mail | Done | +-----------------------------------+-----------------------------------+ |marketing | Nothing to do | +-----------------------------------+-----------------------------------+ From 47e73dc908f0510c50e0c2e5e1b3746c7a961382 Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Thu, 18 Dec 2014 17:06:26 +0100 Subject: [PATCH 4/4] [IMP] Remove setting a default unnecessarily [FIX] Don't call map_values with the same source and target table [ADD] Load noupdate data --- .../migrations/8.0.1.0/noupdate_changes.xml | 9 +++++++++ .../8.0.1.0/openupgrade_analysis_work.txt | 10 ++++++---- .../mail/migrations/8.0.1.0/post-migration.py | 17 +++++++---------- addons/mail/migrations/8.0.1.0/pre-migration.py | 3 +-- 4 files changed, 23 insertions(+), 16 deletions(-) create mode 100644 addons/mail/migrations/8.0.1.0/noupdate_changes.xml diff --git a/addons/mail/migrations/8.0.1.0/noupdate_changes.xml b/addons/mail/migrations/8.0.1.0/noupdate_changes.xml new file mode 100644 index 000000000000..52bb89e31c73 --- /dev/null +++ b/addons/mail/migrations/8.0.1.0/noupdate_changes.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/addons/mail/migrations/8.0.1.0/openupgrade_analysis_work.txt b/addons/mail/migrations/8.0.1.0/openupgrade_analysis_work.txt index b76b90b1ddcd..ab8e510928d6 100644 --- a/addons/mail/migrations/8.0.1.0/openupgrade_analysis_work.txt +++ b/addons/mail/migrations/8.0.1.0/openupgrade_analysis_work.txt @@ -1,12 +1,14 @@ ---Fields in module 'mail'--- mail / mail.alias / alias_contact (selection) : NEW required: required, selection_keys: ['everyone', 'followers', 'partners'], req_default: everyone +# Nothing to do mail / mail.alias / alias_parent_model_id (many2one): NEW relation: ir.model mail / mail.alias / alias_parent_thread_id (integer): NEW +# Done: populated using update_alias mail / mail.mail / recipient_ids (many2many) : NEW relation: res.partner mail / mail.message / record_name (char) : not a function anymore mail / mail.message.subtype / hidden (boolean) : NEW mail / mail.message.subtype / sequence (integer) : NEW -# Nothing to do +# Nothing to do. Setting non-default sequence for mt_comment through data file. mail / mail.group / message_last_post (datetime) : NEW # Done @@ -23,7 +25,7 @@ mail / mail.thread / message_ids (one2many) : module mail / mail.thread / message_is_follower (boolean) : module is now 'website_mail' ('mail') mail / mail.thread / message_summary (text) : module is now 'website_mail' ('mail') mail / mail.thread / message_unread (boolean) : module is now 'website_mail' ('mail') -# Calculated functional fields, nothing to do. +# Calculated function fields, nothing to do. mail / res.partner / message_last_post (datetime) : NEW # Done @@ -33,7 +35,7 @@ mail / res.partner / notification_email_send (selection): w # Done mail / res.users / display_groups_suggestions (boolean): NEW -# Set defaults: Done +# Nothing to do: default value is set automatically ---XML records in module 'mail'--- NEW ir.actions.act_window: base.action_attachment @@ -45,4 +47,4 @@ NEW ir.rule: mail.mail_followers_read_write_others NEW ir.ui.view: mail.assets_backend NEW ir.ui.view: mail.view_document_file_kanban NEW res.partner: base.partner_root -# Nothing to do \ No newline at end of file +# Nothing to do diff --git a/addons/mail/migrations/8.0.1.0/post-migration.py b/addons/mail/migrations/8.0.1.0/post-migration.py index 6dec5da5639a..f9abd3333c24 100644 --- a/addons/mail/migrations/8.0.1.0/post-migration.py +++ b/addons/mail/migrations/8.0.1.0/post-migration.py @@ -26,12 +26,6 @@ from openerp import pooler, SUPERUSER_ID as uid from openerp.openupgrade import openupgrade, openupgrade_80 -default_spec = { - 'res.users': [ - ('display_groups_suggestions', True), - ], -} - def mail_mail_to_mail_message_migration(cr, uid, pool): """ @@ -53,9 +47,10 @@ def mail_mail_to_mail_message_migration(cr, uid, pool): def map_notify_email(cr): openupgrade.map_values( cr, + openupgrade.get_legacy_name('notification_email_send'), 'notify_email', - 'notify_email', - [('all', 'always'), ('comment', 'always'), ('email', 'always'), ('none', 'none')], + [('all', 'always'), ('comment', 'always'), + ('email', 'always'), ('none', 'none')], table='res_partner', write='sql') @@ -65,7 +60,9 @@ def migrate(cr, version): map_notify_email(cr) mail_mail_to_mail_message_migration(cr, uid, pool) - openupgrade_80.set_message_last_post(cr, uid, pool, ['res.partner', 'mail.group']) - openupgrade.set_defaults(cr, pool, default_spec, force=False) + openupgrade_80.set_message_last_post( + cr, uid, pool, ['res.partner', 'mail.group']) openupgrade_80.update_aliases(cr, pool, 'mail.group', True) openupgrade_80.update_aliases(cr, pool, 'res.users', True) + openupgrade.load_data( + cr, 'mail', 'migrations/8.0.1.0/noupdate_changes.xml') diff --git a/addons/mail/migrations/8.0.1.0/pre-migration.py b/addons/mail/migrations/8.0.1.0/pre-migration.py index ec0e3b3b16e6..3c6c969b2f48 100644 --- a/addons/mail/migrations/8.0.1.0/pre-migration.py +++ b/addons/mail/migrations/8.0.1.0/pre-migration.py @@ -25,11 +25,10 @@ column_renames = { 'res_partner': [ - ('notification_email_send', 'notify_email'), + ('notification_email_send', None), ], 'mail_mail': [ ('email_from', None), - ('mail_server_id', None), ('reply_to', None), ]