Skip to content
Merged
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
9 changes: 9 additions & 0 deletions addons/mail/migrations/8.0.1.0/noupdate_changes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version='1.0' encoding='utf-8'?>
<openerp>
<data>
<record model="ir.rule" id="mail_followers_read_write_own"><field name="groups" eval="[(4, ref('base.group_user'))]"/>
</record>
<record model="mail.message.subtype" id="mt_comment"><field name="sequence" eval="0"/>
</record>
</data>
</openerp>
50 changes: 50 additions & 0 deletions addons/mail/migrations/8.0.1.0/openupgrade_analysis_work.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---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. Setting non-default sequence for mt_comment through data file.

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 function 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
# Nothing to do: default value is set automatically

---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
68 changes: 68 additions & 0 deletions addons/mail/migrations/8.0.1.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2010 - 2014 Savoir-faire Linux
# (<http://www.savoirfairelinux.com>).
# (<http://www.akretion.com>).
# @author: Onestein <www.onestein.nl>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################


from openerp import pooler, SUPERUSER_ID as uid
from openerp.openupgrade import openupgrade, openupgrade_80


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,
openupgrade.get_legacy_name('notification_email_send'),
'notify_email',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As pointed by @christophlsa in #162, this function gives an error. But I have to say that the method is correct and you have to change this call: the check is intended to prevent to overwrite a column with unintended consequences, and also to be conservative, letting in legacy column the old values. Imagine this case: [('all', 'always'), ('always', 'none')]. The first mapping will set all values to always, and the second one will map all values (old 'all' values, and current 'always' values), so this in not what we want.

[('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_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')
40 changes: 40 additions & 0 deletions addons/mail/migrations/8.0.1.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2014 Akretion (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# (<http://www.savoirfairelinux.com>).
# @author: Onestein <www.onestein.nl>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################

from openerp.openupgrade import openupgrade

column_renames = {
'res_partner': [
('notification_email_send', None),
],
'mail_mail': [
('email_from', None),
('mail_server_id', None),
('reply_to', None),
]
}


@openupgrade.migrate()
def migrate(cr, version):
openupgrade.rename_columns(cr, column_renames)
2 changes: 1 addition & 1 deletion openerp/openupgrade/doc/source/modules70-80.rst
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ Status :
+-----------------------------------+-----------------------------------+
|lunch | Nothing to do |
+-----------------------------------+-----------------------------------+
|mail | |
|mail | Done |
+-----------------------------------+-----------------------------------+
|marketing | Nothing to do |
+-----------------------------------+-----------------------------------+
Expand Down