Merge lp:~therp-nl/openupgrade-addons/6.1-migrate_email_composition_actions into lp:openupgrade-addons/6.1

Proposed by Stefan Rijnhart (Opener)
Status: Merged
Merged at revision: 6607
Proposed branch: lp:~therp-nl/openupgrade-addons/6.1-migrate_email_composition_actions
Merge into: lp:openupgrade-addons/6.1
Diff against target: 97 lines (+65/-10)
2 files modified
email_template/migrations/6.1.1.1/post-migration.py (+61/-0)
email_template/migrations/6.1.1.1/pre-migration.py (+4/-10)
To merge this branch: bzr merge lp:~therp-nl/openupgrade-addons/6.1-migrate_email_composition_actions
Reviewer Review Type Date Requested Status
OpenUpgrade Committers Pending
Review via email: mp+130099@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'email_template/migrations/6.1.1.1/post-migration.py'
--- email_template/migrations/6.1.1.1/post-migration.py 1970-01-01 00:00:00 +0000
+++ email_template/migrations/6.1.1.1/post-migration.py 2012-10-17 12:11:24 +0000
@@ -0,0 +1,61 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This module copyright (C) 2012 Therp BV (<http://therp.nl>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import pooler, logging
23from openerp import SUPERUSER_ID
24from openerp.tools.safe_eval import safe_eval
25from openerp.openupgrade import openupgrade
26
27def update_actions(cr, pool):
28 """
29 Update act windows that trigger an email form action. The template id
30 is encloded differently in the action's context and the name and view_id of the
31 wizard has changed as well.
32 """
33 cr.execute("""
34 SELECT id, context FROM ir_act_window
35 WHERE res_model = 'email_template.send.wizard'
36 """)
37 data_pool = pool.get('ir.model.data')
38 view_id = data_pool.get_object_reference(
39 cr, SUPERUSER_ID, 'mail', 'email_compose_message_wizard_form')[1]
40 for row in cr.fetchall():
41 try:
42 old_context = safe_eval(row[1] or {}, {'active_id': False, 'active_ids': False})
43 if old_context.get('template_id'):
44 new_context = (
45 "{'mail.compose.message.mode':'mass_mail', "
46 "'mail.compose.template_id' : %s}" % (old_context['template_id']))
47 openupgrade.logged_query(cr, """
48 UPDATE ir_act_window
49 SET res_model = %s,
50 view_id = %s,
51 context = %s
52 WHERE id = %s
53 """, ('mail.compose.message', view_id, new_context, row[0]))
54 except NameError, e:
55 logger = logging.getLogger('OpenUpgrade')
56 logger.warn('Could not evaluate %s: %s', old_context, e)
57
58@openupgrade.migrate()
59def migrate(cr, version):
60 pool = pooler.get_pool(cr.dbname)
61 update_actions(cr, pool)
062
=== modified file 'email_template/migrations/6.1.1.1/pre-migration.py'
--- email_template/migrations/6.1.1.1/pre-migration.py 2012-06-19 09:34:23 +0000
+++ email_template/migrations/6.1.1.1/pre-migration.py 2012-10-17 12:11:24 +0000
@@ -19,8 +19,6 @@
19#19#
20##############################################################################20##############################################################################
2121
22import os
23from osv import osv
24import logging22import logging
25from openerp.openupgrade import openupgrade23from openerp.openupgrade import openupgrade
2624
@@ -59,14 +57,10 @@
59 "FROM email_template_account WHERE "57 "FROM email_template_account WHERE "
60 "email_template.from_account = email_template_account.id")58 "email_template.from_account = email_template_account.id")
6159
60@openupgrade.migrate()
62def migrate(cr, version):61def migrate(cr, version):
63 if not version:62 if not version:
64 return63 return
65 try:64 openupgrade.rename_columns(cr, column_renames)
66 logger.info("%s called", me)65 fix_email_from(cr)
67 if not openupgrade.column_exists(cr, 'email_template', 'user_signature'):66 openupgrade.delete_model_workflow(cr, 'email_template.account')
68 openupgrade.rename_columns(cr, column_renames)
69 fix_email_from(cr)
70 openupgrade.delete_model_workflow(cr, 'email_template.account')
71 except Exception, e:
72 raise osv.except_osv("OpenUpgrade", '%s: %s' % (me, e))

Subscribers

People subscribed via source and target branches