[ADD] emails :- add email.message send wizard.

bzr revid: ysa@tinyerp.com-20110217105844-sj5o5y1qmszp6mtw
This commit is contained in:
Yogesh (OpenERP) 2011-02-17 16:28:44 +05:30
parent a084e73585
commit 99c4933b50
5 changed files with 13 additions and 11 deletions

View File

@ -451,14 +451,12 @@ This is useful for CRM leads for example"),
def generate_email(self, cr, uid, ids, record_id, context=None):
def generate_email(self, cr, uid, template_id, record_id, context=None):
if context is None:
context = {}
email_ids = []
for template in self.browse(cr, uid, ids, context=context):
email_id = self._generate_email(cr, uid, template.id, record_id, context)
email_ids.append(email_id)
return email_ids
email_id = self._generate_email(cr, uid, template_id, record_id, context)
return email_id
email_template()
class email_message(osv.osv):
@ -481,15 +479,17 @@ class email_message(osv.osv):
message_id=False, openobject_id=False, debug=False, subtype='plain', x_headers={}, priority='3', smtp_server_id=False, context=None):
if context is None:
context = {}
notemplate = context.get('notemplate', False)
notemplate = context.get('notemplate', True)
if (not notemplate) and model and openobject_id:
template_pool = self.pool.get('email.template')
template_ids = template_pool.search(cr, uid, [('model','=',model)])
if template_ids and len(template_ids):
template_id = template_ids[0]
return template_pool.generate_email(cr, uid, [template_id], openobject_id, context=context)
return template_pool.generate_email(cr, uid, template_id, openobject_id, context=context)
return super(email_message, self).email_send(cr, uid, email_from, email_to, subject, body, model=model, email_cc=email_cc, email_bcc=email_bcc, reply_to=reply_to, attach=attach,
message_id=message_id, openobject_id=openobject_id, debug=debug, subtype=subtype, x_headers=x_headers, priority=priority, smtp_server_id=smtp_server_id, context=context)
email_message()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -22,6 +22,7 @@
import email_smtp_server
import email_message
import res_partner
import wizard
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -32,11 +32,11 @@
'depends': ['base', 'base_tools'],
'init_xml': [],
'update_xml': [
"wizard/email_message_wizard_send_view.xml",
"email_view.xml",
"res_partner_view.xml",
'security/ir.model.access.csv',
'email_data.xml',
],
'demo_xml': [],
'installable': True,

View File

@ -284,7 +284,7 @@ class email_message(osv.osv):
for attachment in attach:
attachment_data = {
'name': (subject or '') + _(' (Email Attachment)'),
'datas': base64.b64encode(attachment[1]),
'datas': attachment[1],
'datas_fname': attachment[0],
'description': subject or _('No Description'),
'res_model':'email.message',

View File

@ -3,7 +3,7 @@
<data>
<menuitem name="Configuration" parent="base.menu_tools"
id="base.menu_lunch_survey_root" sequence="20" />
id="base.menu_lunch_survey_root" sequence="20"/>
<record model="ir.ui.view" id="view_email_message_form">
<field name="name">email.message.form</field>
@ -34,6 +34,7 @@
<field name="res_id" readonly="1"/>
<button name="open_document" string="Open Document" type="object" icon="gtk-jump-to"/>
<field name="message_id"/>
<button name="%(action_email_message_wizard_send)d" string="Reply" type="action" icon="terp-mail-replied"/>
</group>
</group>
<separator string="Description" colspan="4"/>