From 8f9f45ea948d1ffecb79601e860d522fc6686c2d Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 22 Aug 2011 19:16:59 +0200 Subject: [IMP] all: next pass of review/renaming for new mail API bzr revid: odo@openerp.com-20110822171659-zxho36a6n628i10q --- addons/crm/wizard/mail_compose_message.py | 61 +++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 addons/crm/wizard/mail_compose_message.py (limited to 'addons/crm/wizard/mail_compose_message.py') diff --git a/addons/crm/wizard/mail_compose_message.py b/addons/crm/wizard/mail_compose_message.py new file mode 100644 index 00000000000..c11f4d8c29d --- /dev/null +++ b/addons/crm/wizard/mail_compose_message.py @@ -0,0 +1,61 @@ +# -*- 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 + +SUPPORTED_MODELS = ['crm.lead',] + +class mail_compose_message(osv.osv_memory): + _inherit = 'mail.compose.message' + + def get_value(self, cr, uid, model, res_id, context=None): + """Returns a defaults-like dict with initial values for the composition + wizard when sending an email related to the document record identified + by ``model`` and ``res_id``. + + Overrides the default implementation to provide more default field values + related to the corresponding CRM case. + + :param str model: model name of the document record this mail is related to. + :param int res_id: id of the document record this mail is related to. + :param dict context: several context values will modify the behavior + of the wizard, cfr. the class description. + """ + result = super(mail_compose_message, self).get_value(cr, uid, model, res_id, context=context) + if model in SUPPORTED_MODELS and res_id: + model_obj = self.pool.get(model) + data = model_obj.browse(cr, uid , res_id, context) + result.update({ + 'subject' : data.name or False, + 'email_to' : data.email_from or False, + 'email_from' : data.user_id and data.user_id.address_id and data.user_id.address_id.email or tools.config.get('email_from', False), + 'body_text' : '\n' + (tools.ustr(data.user_id.signature or '')), + 'email_cc' : tools.ustr(data.email_cc or ''), + 'model': model, + 'res_id': res_id, + }) + if hasattr(data, 'section_id'): + result.update({'reply_to' : data.section_id and data.section_id.reply_to or False}) + return result + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: -- cgit v1.2.3 From e9d94b824eee6970bf3263d7d0fd3208a3b0f037 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Tue, 6 Sep 2011 10:00:14 +0200 Subject: [IMP]: crm,mail: minor fixes after review bzr revid: odo@openerp.com-20110906080014-6texz097jepfrwsp --- addons/crm/wizard/mail_compose_message.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'addons/crm/wizard/mail_compose_message.py') diff --git a/addons/crm/wizard/mail_compose_message.py b/addons/crm/wizard/mail_compose_message.py index c11f4d8c29d..d54f227e64c 100644 --- a/addons/crm/wizard/mail_compose_message.py +++ b/addons/crm/wizard/mail_compose_message.py @@ -48,11 +48,12 @@ class mail_compose_message(osv.osv_memory): result.update({ 'subject' : data.name or False, 'email_to' : data.email_from or False, - 'email_from' : data.user_id and data.user_id.address_id and data.user_id.address_id.email or tools.config.get('email_from', False), + 'email_from' : data.user_id.user_email if data.user_id else tools.config.get('email_from', False), 'body_text' : '\n' + (tools.ustr(data.user_id.signature or '')), 'email_cc' : tools.ustr(data.email_cc or ''), 'model': model, 'res_id': res_id, + 'subtype': 'plain', }) if hasattr(data, 'section_id'): result.update({'reply_to' : data.section_id and data.section_id.reply_to or False}) -- cgit v1.2.3 From 98165a1522b4b443871bfd00b9c925b11c61ebf2 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Wed, 7 Sep 2011 19:11:27 +0200 Subject: [IMP] crm: mail composition wizard - better defaults bzr revid: odo@openerp.com-20110907171127-shibkhmoi7ptbw1u --- addons/crm/wizard/mail_compose_message.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'addons/crm/wizard/mail_compose_message.py') diff --git a/addons/crm/wizard/mail_compose_message.py b/addons/crm/wizard/mail_compose_message.py index d54f227e64c..512d9ece77a 100644 --- a/addons/crm/wizard/mail_compose_message.py +++ b/addons/crm/wizard/mail_compose_message.py @@ -45,11 +45,12 @@ class mail_compose_message(osv.osv_memory): if model in SUPPORTED_MODELS and res_id: model_obj = self.pool.get(model) data = model_obj.browse(cr, uid , res_id, context) + user = self.pool.get('res.users').browse(cr, uid, uid, context=context) result.update({ 'subject' : data.name or False, 'email_to' : data.email_from or False, - 'email_from' : data.user_id.user_email if data.user_id else tools.config.get('email_from', False), - 'body_text' : '\n' + (tools.ustr(data.user_id.signature or '')), + 'email_from' : user.user_email or tools.config.get('email_from', False), + 'body_text' : '\n' + tools.ustr(user.signature), 'email_cc' : tools.ustr(data.email_cc or ''), 'model': model, 'res_id': res_id, -- cgit v1.2.3