summaryrefslogtreecommitdiff
path: root/addons/mail/wizard
diff options
context:
space:
mode:
authorTejas Tank <tta@openerp.com>2012-07-16 17:16:51 +0530
committerTejas Tank <tta@openerp.com>2012-07-16 17:16:51 +0530
commitd5d2e420161e7ecdbdbecedd8b47c54033af3c8a (patch)
tree8c5d9674e5c8f215206b5557945fbfd87d5a99c1 /addons/mail/wizard
parentc50debfbd328c472c2c247bfb66d768256fe994b (diff)
parent08d2eb4828398b2deae80bb7d7bcd7436db1bb57 (diff)
[IMP] code improve and merge with latest.
bzr revid: tta@openerp.com-20120716114651-19wmcwhj7f6b4qj9
Diffstat (limited to 'addons/mail/wizard')
-rw-r--r--addons/mail/wizard/mail_compose_message.py39
-rw-r--r--addons/mail/wizard/mail_compose_message_view.xml10
2 files changed, 44 insertions, 5 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:
diff --git a/addons/mail/wizard/mail_compose_message_view.xml b/addons/mail/wizard/mail_compose_message_view.xml
index 3da63fb1adc..bcc11c4111d 100644
--- a/addons/mail/wizard/mail_compose_message_view.xml
+++ b/addons/mail/wizard/mail_compose_message_view.xml
@@ -7,11 +7,6 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Compose Email" version="7.0">
- <header>
- <button name="send_mail" string="Send" type="object" class="oe_highlight" />
- or
- <button string="Cancel" class="oe_link" special="cancel" />
- </header>
<group>
<field name="model" invisible="1"/>
<field name="res_id" invisible="1"/>
@@ -33,6 +28,11 @@
<field name="attachment_ids" colspan="4" nolabel="1"/>
</page>
</notebook>
+ <footer>
+ <button name="send_mail" string="Send" type="object" class="oe_highlight" />
+ or
+ <button string="Cancel" class="oe_link" special="cancel" />
+ </footer>
</form>
</field>
</record>