[IMP] email_message.py: improvements in send_email and change references
bzr revid: rha@tinyerp.com-20110328135224-nshd4lbsmdgm4xr5
This commit is contained in:
parent
24883b8c57
commit
974e45de8a
|
@ -235,6 +235,7 @@ class email_message(osv.osv):
|
|||
attachment_ids = []
|
||||
for attachment in attach:
|
||||
attachment_data = {
|
||||
'name': attachment[0],
|
||||
'subject': (subject or '') + _(' (Email Attachment)'),
|
||||
'datas': attachment[1],
|
||||
'datas_fname': attachment[0],
|
||||
|
@ -265,9 +266,6 @@ class email_message(osv.osv):
|
|||
self.write(cr, uid, ids, {'state':'outgoing'}, context)
|
||||
for message in self.browse(cr, uid, ids, context):
|
||||
try:
|
||||
attachments = []
|
||||
for attach in message.attachment_ids:
|
||||
attachments.append((attach.datas_fname ,base64.b64decode(attach.datas)))
|
||||
smtp_server = message.smtp_server_id
|
||||
if not smtp_server:
|
||||
smtp_ids = smtp_server_obj.search(cr, uid, [])
|
||||
|
@ -287,13 +285,14 @@ class email_message(osv.osv):
|
|||
def send_email(self, cr, uid, ids, auto_commit=False, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
attachment = []
|
||||
smtp_server_obj = self.pool.get('ir.mail_server')
|
||||
attachment_pool = self.pool.get('ir.attachment')
|
||||
for message in self.browse(cr, uid, ids, context):
|
||||
try:
|
||||
if message.state in ['outgoing', 'exception']:
|
||||
result = smtp_server_obj.send_email(cr, uid, message.email_from, message.email_to,
|
||||
message.body, id=message.smtp_server_id.id, subject=message.subject)
|
||||
message, id=message.smtp_server_id.id or False, subject=message.subject)
|
||||
else:
|
||||
raise osv.except_osv(_('Error !'), _('No messages in outgoing or exception state!'))
|
||||
|
||||
|
|
|
@ -394,7 +394,7 @@ This is useful for CRM leads for example"),
|
|||
|
||||
elif template['track_campaign_item']:
|
||||
# get appropriate message-id
|
||||
values.update({'message_id': tools.misc.generate_tracking_message_id(record_id)})
|
||||
values.update({'message_id': smtp_pool.generate_tracking_message_id(record_id)})
|
||||
|
||||
#Use signatures if allowed
|
||||
if template.user_signature:
|
||||
|
|
|
@ -93,7 +93,8 @@ class email_template_preview(osv.osv_memory):
|
|||
if template.message_id:
|
||||
vals['message_id'] = self.get_template_value(cr, uid, message_id, model, res_id, context)
|
||||
elif template.track_campaign_item:
|
||||
vals['message_id'] = tools.misc.generate_tracking_message_id(res_id)
|
||||
smtp_server_obj = self.pool.get('ir.mail_server')
|
||||
vals['message_id'] = smtp_server_obj.generate_tracking_message_id(res_id)
|
||||
vals['subject'] = self.get_template_value(cr, uid, template.subject, model, res_id, context)
|
||||
description = self.get_template_value(cr, uid, template.body, model, res_id, context) or ''
|
||||
if template.user_signature:
|
||||
|
|
Loading…
Reference in New Issue