-
-
Notifications
You must be signed in to change notification settings - Fork 820
Add pre and post migration scripts for mail #64
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
addons/mail/migrations/8.0.1.0/openupgrade_analysis_work.txt
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| ---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 | ||
| mail / res.users / display_groups_suggestions (boolean): NEW | ||
| ## Nothing to do | ||
|
|
||
| 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') | ||
| # TODO Added after initial analysis | ||
|
|
||
| mail / mail.group / message_last_post (datetime) : NEW | ||
| mail / res.partner / message_last_post (datetime) : NEW | ||
| ## TODO something with last_post in openupgrade80 | ||
|
|
||
| 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] | ||
| ## all, comment, email -> always, none -> none | ||
|
|
||
| mail / mail.mail / email_from (char) : DEL | ||
| ## Possibly moved to mail.message, nothing done | ||
|
|
||
| mail / mail.mail / mail_server_id (many2one) : DEL relation: ir.mail_server | ||
| mail / mail.mail / reply_to (char) : DEL | ||
| mail / mail.message / mail_server_id (many2one) : NEW relation: ir.mail_server | ||
| mail / mail.message / reply_to (char) : NEW | ||
| ## Moved from mail.mail to mail.message | ||
|
|
||
| ---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 | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # -*- encoding: utf-8 -*- | ||
| ############################################################################## | ||
| # | ||
| # OpenERP, Open Source Management Solution | ||
| # This module copyright (C) 2010 - 2014 Savoir-faire Linux | ||
| # (<http://www.savoirfairelinux.com>). | ||
| # | ||
| # 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 | ||
| 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, )) | ||
|
|
||
|
|
||
| @openupgrade.migrate() | ||
| def migrate(cr, version): | ||
| pool = pooler.get_pool(cr.dbname) | ||
| uid = SUPERUSER_ID | ||
| mail_mail_to_mail_message_migration(cr, uid, pool) | ||
| openupgrade_80.set_message_last_post( | ||
| cr, uid, pool, ['mail.group', 'res.partner']) |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # -*- encoding: utf-8 -*- | ||
| ############################################################################## | ||
| # | ||
| # OpenERP, Open Source Management Solution | ||
| # This module copyright (C) 2010 - 2014 Savoir-faire Linux | ||
| # (<http://www.savoirfairelinux.com>). | ||
| # | ||
| # 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', 'notify_email'), | ||
|
|
||
| ], | ||
| 'mail_mail': [ | ||
| ('email_from', None), | ||
| # The following fields are to be moved to mail_message in post | ||
| ('mail_server_id', None), | ||
| ('reply_to', None), | ||
| ] | ||
| } | ||
|
|
||
|
|
||
| def partner_notify_migration(cr): | ||
| """The selection values 'all', 'comment' and 'email' got replaced by | ||
| 'always', 'never' is still 'never'""" | ||
| openupgrade.logged_query(cr, """ | ||
| UPDATE res_partner | ||
| SET notify_email = 'always' | ||
| WHERE notify_email IN ('all', 'comment', 'email')""") | ||
|
|
||
|
|
||
| @openupgrade.migrate() | ||
| def migrate(cr, version): | ||
| openupgrade.rename_columns(cr, column_renames) | ||
| partner_notify_migration(cr) |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the new alias_parent* fields enable a button 'open_parent_document' from the alias view. This allows quick navigation from a task alias to the associated project. I guess the values for these fields will have to be filled in their respective modules. It looks like the create method of the models show us with which values to fill them. I find these fields in
crm/res_config.py
crm/sales_team.py
hr_recruitment/hr_recruitment.py
hr_recruitment/res_config.py
mail/mail_group.py
mail/res_users.py
project/project.py
See the project migration that I now adapted: 0ab9e69
You should do similarly for the mail.group and res.users model, because their aliases are created in this module.