[IMP] email_template, emails:- message id and reference write in message add reference argument in email_send method.
bzr revid: ysa@tinyerp.com-20110223122228-iyzw7mdfvw0zrzw8
This commit is contained in:
parent
30bde91c88
commit
174534ff5e
|
@ -477,7 +477,7 @@ class email_message(osv.osv):
|
|||
return result
|
||||
|
||||
def email_send(self, cr, uid, email_from, email_to, subject, body, model=False, email_cc=None, email_bcc=None, reply_to=False, attach=None,
|
||||
message_id=False, openobject_id=False, debug=False, subtype='plain', x_headers={}, priority='3', smtp_server_id=False, context=None):
|
||||
message_id=False, references=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', True)
|
||||
|
@ -489,7 +489,7 @@ class email_message(osv.osv):
|
|||
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)
|
||||
message_id=message_id, references=references, openobject_id=openobject_id, debug=debug, subtype=subtype, x_headers=x_headers, priority=priority, smtp_server_id=smtp_server_id, context=context)
|
||||
|
||||
email_message()
|
||||
|
||||
|
|
|
@ -36,7 +36,11 @@ class email_compose_message(osv.osv_memory):
|
|||
record_ids = []
|
||||
email_temp_pool = self.pool.get('email.template')
|
||||
model = False
|
||||
if context.get('email_model',False):
|
||||
if context.get('message_id'):
|
||||
message_pool = self.pool.get('email.message')
|
||||
message_data = message_pool.browse(cr, uid, int(context.get('message_id')), context)
|
||||
model = message_data.model
|
||||
elif context.get('email_model',False):
|
||||
model = context.get('email_model')
|
||||
elif context.get('active_model',False):
|
||||
model = context.get('active_model')
|
||||
|
@ -55,6 +59,10 @@ class email_compose_message(osv.osv_memory):
|
|||
email_temp_previ_pool = self.pool.get('email_template.preview')
|
||||
result = self.on_change_referred_doc(cr, uid, [], model, resource_id, context=context)
|
||||
vals = result.get('value',{})
|
||||
if template_id:
|
||||
email_temp_pool = self.pool.get('email.template')
|
||||
email_temp_data = email_temp_pool.browse(cr, uid, template_id, context)
|
||||
vals.update({'smtp_server_id': email_temp_data.smtp_server_id and email_temp_data.smtp_server_id.id or False})
|
||||
if template_id and resource_id:
|
||||
context.update({'template_id': template_id})
|
||||
value = email_temp_previ_pool.on_change_ref(cr, uid, [], resource_id, context)
|
||||
|
|
|
@ -85,6 +85,10 @@ class email_message_template(osv.osv_memory):
|
|||
'description': fields.text('Description', translate=True),
|
||||
'smtp_server_id':fields.many2one('email.smtp_server', 'SMTP Server'),
|
||||
}
|
||||
_defaults = {
|
||||
'references': lambda * a: None,
|
||||
}
|
||||
|
||||
_sql_constraints = []
|
||||
email_message_template()
|
||||
|
||||
|
@ -247,7 +251,7 @@ class email_message(osv.osv):
|
|||
_("Error sending mail: %s") % e)
|
||||
|
||||
def email_send(self, cr, uid, email_from, email_to, subject, body, model=False, email_cc=None, email_bcc=None, reply_to=False, attach=None,
|
||||
message_id=False, openobject_id=False, debug=False, subtype='plain', x_headers={}, priority='3', smtp_server_id=False, context=None):
|
||||
message_id=False, references=False, openobject_id=False, debug=False, subtype='plain', x_headers={}, priority='3', smtp_server_id=False, context=None):
|
||||
attachment_obj = self.pool.get('ir.attachment')
|
||||
if email_to and type(email_to) != list:
|
||||
email_to = [email_to]
|
||||
|
@ -269,6 +273,7 @@ class email_message(osv.osv):
|
|||
'reply_to': reply_to,
|
||||
'res_id': openobject_id,
|
||||
'message_id': message_id,
|
||||
'references': references,
|
||||
'sub_type': subtype or '',
|
||||
'headers': x_headers or False,
|
||||
'priority': priority,
|
||||
|
@ -327,7 +332,8 @@ class email_message(osv.osv):
|
|||
email_cc=message.email_cc and message.email_cc.split(',') or [],
|
||||
email_bcc=message.email_bcc and message.email_bcc.split(',') or [],
|
||||
reply_to=message.reply_to,
|
||||
attach=attachments, message_id=message.message_id, openobject_id=message.res_id,
|
||||
attach=attachments, message_id=message.message_id, references = message.references,
|
||||
openobject_id=message.res_id,
|
||||
subtype=message.sub_type,
|
||||
x_headers=message.headers and eval(message.headers) or {},
|
||||
priority=message.priority, debug=message.debug,
|
||||
|
@ -337,7 +343,7 @@ class email_message(osv.osv):
|
|||
smtp_user=smtp_server and smtp_server.smtpuname or None,
|
||||
smtp_password=smtp_server and smtp_server.smtppass or None)
|
||||
if res:
|
||||
self.write(cr, uid, [message.id], {'state':'sent'}, context)
|
||||
self.write(cr, uid, [message.id], {'state':'sent', 'message_id': res}, context)
|
||||
else:
|
||||
self.write(cr, uid, [message.id], {'state':'exception'}, context)
|
||||
except Exception, error:
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
<button name="%(action_email_compose_message_wizard)d" string="Reply" type="action" icon="terp-mail-replied"
|
||||
context="{'mail':'reply', 'message_id':active_id}"/>
|
||||
</group>
|
||||
<field name="references" widget="char" size="4096"/>
|
||||
</group>
|
||||
<separator string="Description" colspan="4"/>
|
||||
<field name="description" nolabel="1" colspan="4"/>
|
||||
|
|
|
@ -112,10 +112,17 @@ class email_compose_message(osv.osv_memory):
|
|||
context = {}
|
||||
record_ids = []
|
||||
model_pool = False
|
||||
if context.get('email_model',False):
|
||||
if context.get('message_id'):
|
||||
message_pool = self.pool.get('email.message')
|
||||
message_data = message_pool.browse(cr, uid, int(context.get('message_id')), context)
|
||||
model_pool = self.pool.get(message_data.model)
|
||||
record_ids = [message_data.res_id]
|
||||
elif context.get('email_model',False):
|
||||
model = context.get('email_model')
|
||||
model_pool = self.pool.get(model)
|
||||
record_ids = model_pool.search(cr, uid, [])
|
||||
record_ids = context.get('record_ids',[])
|
||||
if not record_ids:
|
||||
record_ids = model_pool.search(cr, uid, [])
|
||||
elif context.get('active_model',False):
|
||||
model = context.get('active_model')
|
||||
model_pool = self.pool.get(model)
|
||||
|
@ -153,9 +160,15 @@ class email_compose_message(osv.osv_memory):
|
|||
for mail in self.browse(cr, uid, ids, context=context):
|
||||
for attach in mail.attachment_ids:
|
||||
attachment.append((attach.datas_fname, attach.datas))
|
||||
references = False
|
||||
message_id = False
|
||||
if context.get('mail',False) == 'reply' and mail.message_id:
|
||||
references = mail.references and str(mail.references) != 'False' and mail.references + "," + mail.message_id or mail.message_id
|
||||
else:
|
||||
message_id = mail.message_id
|
||||
email_id = email_message_pool.email_send(cr, uid, mail.email_from, mail.email_to, mail.name, mail.description,
|
||||
model=mail.model, email_cc=mail.email_cc, email_bcc=mail.email_bcc, reply_to=mail.reply_to,
|
||||
attach=attachment, message_id=mail.message_id, openobject_id=int(mail.res_id), debug=mail.debug,
|
||||
attach=attachment, message_id=message_id, references=references, openobject_id=int(mail.res_id), debug=mail.debug,
|
||||
subtype=mail.sub_type, x_headers=mail.headers, priority=mail.priority, smtp_server_id=mail.smtp_server_id and mail.smtp_server_id.id, context=context)
|
||||
email_ids.append(email_id)
|
||||
return email_ids
|
||||
|
|
Loading…
Reference in New Issue