diff options
| author | Ajay Chauhan (OpenERP) <cha@tinyerp.com> | 2012-07-10 15:52:01 +0530 |
|---|---|---|
| committer | Ajay Chauhan (OpenERP) <cha@tinyerp.com> | 2012-07-10 15:52:01 +0530 |
| commit | 6dbd4e000dcb22d2ffcfeb7a9080eeffcbbcc7f8 (patch) | |
| tree | 5d1c3d763d9282312b22ca9e226515f20ce37d47 /addons/mail/wizard/mail_compose_message.py | |
| parent | 4e08b80952c7f50357f8f97b69495562631e9d55 (diff) | |
| parent | f25ad676a34670f4ba1ac14bf2d6babd8ccc88b5 (diff) | |
[MERGE] merge with parent branch
bzr revid: cha@tinyerp.com-20120710102201-h5mjjkoyprp70lf0
Diffstat (limited to 'addons/mail/wizard/mail_compose_message.py')
| -rw-r--r-- | addons/mail/wizard/mail_compose_message.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index cb2ed1eec19..1b19a383c10 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -292,4 +292,43 @@ class mail_compose_message(osv.osv_memory): return tools.ustr(result) return template and EXPRESSION_PATTERN.sub(merge, template) + + +class mail_compose_message_extended(osv.osv_memory): + """ Extension of 'mail.compose.message' to support default field values related + to CRM-like models that follow the following conventions: + + 1. The model object must have an attribute '_mail_compose_message' equal to True. + + 2. The model should define the following fields: + - 'name' as subject of the message (required); + - 'email_from' as destination email address (required); + - 'email_cc' as cc email addresses (required); + - 'section_id.reply_to' as reply-to address (optional). + """ + _inherit = 'mail.compose.message' + + def get_value(self, cr, uid, model, res_id, context=None): + """Overrides the default implementation to provide more default field values + related to the corresponding CRM case. + """ + result = super(mail_compose_message_extended, self).get_value(cr, uid, model, res_id, context=context) + model_obj = self.pool.get(model) + if getattr(model_obj, '_mail_compose_message', False) and res_id: + data = model_obj.browse(cr, uid , res_id, context) + user = self.pool.get('res.users').browse(cr, uid, uid, context=context) + result.update({ + 'model': model, + 'res_id': res_id, + 'email_from': user.user_email or tools.config.get('email_from', False), + 'email_to': data.email_from or False, + 'email_cc': tools.ustr(data.email_cc or ''), + 'subject': data.name or False, + 'body_text': '\n' + tools.ustr(user.signature or ''), + 'subtype': 'plain', + }) + if hasattr(data, 'section_id'): + result['reply_to'] = data.section_id and data.section_id.reply_to or False + return result + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
