diff --git a/addons/crm/crm_opportunity_view.xml b/addons/crm/crm_opportunity_view.xml
index 84d577a173f..cf1220b3172 100644
--- a/addons/crm/crm_opportunity_view.xml
+++ b/addons/crm/crm_opportunity_view.xml
@@ -192,9 +192,9 @@
context="{'model': 'crm.lead' }"
icon="terp-document-new" type="action" />
+ name="%(emails.action_email_compose_message_wizard)d"
+ context="{'mail':'new', 'model': 'crm.lead', 'record_id' : active_id}"
+ icon="terp-mail-message-new" type="action"/>
diff --git a/addons/crm/wizard/__init__.py b/addons/crm/wizard/__init__.py
index 5a2adaa7e26..559214b6b60 100644
--- a/addons/crm/wizard/__init__.py
+++ b/addons/crm/wizard/__init__.py
@@ -20,6 +20,7 @@
##############################################################################
#import crm_send_email
+import email_compose_message
import crm_add_note
import crm_lead_to_partner
diff --git a/addons/crm/wizard/email_compose_message.py b/addons/crm/wizard/email_compose_message.py
new file mode 100644
index 00000000000..9f4f1676a95
--- /dev/null
+++ b/addons/crm/wizard/email_compose_message.py
@@ -0,0 +1,65 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2010-Today OpenERP SA ()
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see
+#
+##############################################################################
+
+from osv import osv
+from osv import fields
+import tools
+
+class email_compose_message(osv.osv_memory):
+ _name = 'email.compose.message'
+ _inherit = 'email.compose.message'
+
+ def default_get(self, cr, uid, fields, context=None):
+ if context is None:
+ context = {}
+ result = super(email_compose_message, self).default_get(cr, uid, fields, context=context)
+ if context.get('record_id',False) and context.get('model',False):
+ model_obj = self.pool.get(context.get('model'))
+ data = model_obj.browse(cr, uid ,context.get('record_id'), context)
+ if 'name' in fields:
+ result['name'] = data.name
+
+ if 'email_to' in fields:
+ result['email_to'] = data.email_from
+
+ if 'email_from' in fields:
+ result['email_from'] = data.user_id and data.user_id.address_id and data.user_id.address_id.email
+
+ if 'description' in fields:
+ result['description'] = '\n' + (tools.ustr(data.user_id.signature or ''))
+
+ if 'model' in fields:
+ result['model'] = context.get('model','')
+
+ if 'email_cc' in fields:
+ result['email_cc'] = tools.ustr(data.email_cc or '')
+
+ if 'res_id' in fields:
+ result['res_id'] = context.get('record_id',0)
+
+ if 'reply_to' in fields and hasattr(data, 'section_id'):
+ result['reply_to'] = data.section_id and data.section_id.reply_to or False
+
+ return result
+
+email_compose_message()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/emails/wizard/email_compose_message.py b/addons/emails/wizard/email_compose_message.py
index fce2a1fd316..738b1561119 100644
--- a/addons/emails/wizard/email_compose_message.py
+++ b/addons/emails/wizard/email_compose_message.py
@@ -34,35 +34,7 @@ class email_compose_message(osv.osv_memory):
result = super(email_compose_message, self).default_get(cr, uid, fields, context=context)
message_pool = self.pool.get('email.message')
message_id = context.get('message_id', False)
- message_data = False
- if context.get('record_id',False) and context.get('model',False):
- model_obj = self.pool.get(context.get('model'))
- data = model_obj.browse(cr, uid ,context.get('record_id'), context)
- if 'name' in fields and hasattr(data, 'name'):
- result['name'] = data.name
-
- if 'email_to' in fields and hasattr(data, 'email_to'):
- result['email_to'] = data.email_from
-
- if 'email_from' in fields and hasattr(data, 'email_from'):
- result['email_from'] = data.user_id and data.user_id.address_id and data.user_id.address_id.email
-
- if 'description' in fields and hasattr(data, 'description'):
- result['description'] = '\n' + (tools.ustr(data.user_id.signature or ''))
-
- if 'model' in fields:
- result['model'] = context.get('model','')
-
- if 'email_cc' in fields and hasattr(data, 'email_cc'):
- result['email_cc'] = tools.ustr(data.email_cc or '')
-
- if 'res_id' in fields:
- result['res_id'] = context.get('record_id',0)
-
- if 'reply_to' in fields and hasattr(data, 'reply_to'):
- result['reply_to'] = data.section_id and data.section_id.reply_to or False
-
- elif message_id:
+ if message_id:
message_data = message_pool.browse(cr, uid, int(message_id), context)
if 'message_id' in fields:
result['message_id'] = message_data and message_data.message_id
diff --git a/addons/emails/wizard/email_compose_message_view.xml b/addons/emails/wizard/email_compose_message_view.xml
index c34b194bf87..f23a718ad76 100644
--- a/addons/emails/wizard/email_compose_message_view.xml
+++ b/addons/emails/wizard/email_compose_message_view.xml
@@ -44,7 +44,6 @@
formformnew
- {'message_id':active_id, 'mail':'reply'}