[IMP] crm :- inherit email.compose.message wizard and override default_get method and set default value to related module.

bzr revid: ysa@tinyerp.com-20110221103907-l114g3ugjr57yxnd
This commit is contained in:
Yogesh (OpenERP)
2011-02-21 16:09:07 +05:30
parent 748860ca60
commit 368808a4bb
5 changed files with 70 additions and 33 deletions
+3 -3
View File
@@ -192,9 +192,9 @@
context="{'model': 'crm.lead' }"
icon="terp-document-new" type="action" />
<button string="Send New Email"
name="action_send_email"
context="{'mail':'new', 'model': 'crm.lead', 'rec_id' : active_id}"
icon="terp-mail-message-new" type="object" />
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"/>
</page>
<page string="Extra Info" groups="base.group_extended">
<group col="2" colspan="2">
+1
View File
@@ -20,6 +20,7 @@
##############################################################################
#import crm_send_email
import email_compose_message
import crm_add_note
import crm_lead_to_partner
@@ -0,0 +1,65 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2010-Today OpenERP SA (<http://www.openerp.com>)
#
# 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 <http://www.gnu.org/licenses/>
#
##############################################################################
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:
+1 -29
View File
@@ -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
@@ -44,7 +44,6 @@
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="context">{'message_id':active_id, 'mail':'reply'}</field>
</record>
</data>