Stefan Rijnhart (Therp) has proposed merging lp:~therp-nl/openupgrade-addons/6.1-migrate_email_composition_actions into lp:openupgrade-addons.
Requested reviews: OpenUpgrade Committers (openupgrade-committers) For more details, see: https://code.launchpad.net/~therp-nl/openupgrade-addons/6.1-migrate_email_composition_actions/+merge/130099 -- https://code.launchpad.net/~therp-nl/openupgrade-addons/6.1-migrate_email_composition_actions/+merge/130099 Your team OpenUpgrade Committers is requested to review the proposed merge of lp:~therp-nl/openupgrade-addons/6.1-migrate_email_composition_actions into lp:openupgrade-addons.
=== 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 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2012 Therp BV (<http://therp.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/>. +# +############################################################################## + +import pooler, logging +from openerp import SUPERUSER_ID +from openerp.tools.safe_eval import safe_eval +from openerp.openupgrade import openupgrade + +def update_actions(cr, pool): + """ + Update act windows that trigger an email form action. The template id + is encloded differently in the action's context and the name and view_id of the + wizard has changed as well. + """ + cr.execute(""" + SELECT id, context FROM ir_act_window + WHERE res_model = 'email_template.send.wizard' + """) + data_pool = pool.get('ir.model.data') + view_id = data_pool.get_object_reference( + cr, SUPERUSER_ID, 'mail', 'email_compose_message_wizard_form')[1] + for row in cr.fetchall(): + try: + old_context = safe_eval(row[1] or {}, {'active_id': False, 'active_ids': False}) + if old_context.get('template_id'): + new_context = ( + "{'mail.compose.message.mode':'mass_mail', " + "'mail.compose.template_id' : %s}" % (old_context['template_id'])) + openupgrade.logged_query(cr, """ + UPDATE ir_act_window + SET res_model = %s, + view_id = %s, + context = %s + WHERE id = %s + """, ('mail.compose.message', view_id, new_context, row[0])) + except NameError, e: + logger = logging.getLogger('OpenUpgrade') + logger.warn('Could not evaluate %s: %s', old_context, e) + [email protected]() +def migrate(cr, version): + pool = pooler.get_pool(cr.dbname) + update_actions(cr, pool) === 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 @@ # ############################################################################## -import os -from osv import osv import logging from openerp.openupgrade import openupgrade @@ -59,14 +57,10 @@ "FROM email_template_account WHERE " "email_template.from_account = email_template_account.id") [email protected]() def migrate(cr, version): if not version: return - try: - logger.info("%s called", me) - if not openupgrade.column_exists(cr, 'email_template', 'user_signature'): - openupgrade.rename_columns(cr, column_renames) - fix_email_from(cr) - openupgrade.delete_model_workflow(cr, 'email_template.account') - except Exception, e: - raise osv.except_osv("OpenUpgrade", '%s: %s' % (me, e)) + openupgrade.rename_columns(cr, column_renames) + fix_email_from(cr) + openupgrade.delete_model_workflow(cr, 'email_template.account')
-- Mailing list: https://launchpad.net/~credativ Post to : [email protected] Unsubscribe : https://launchpad.net/~credativ More help : https://help.launchpad.net/ListHelp

