Odoo Help


openchatter message how send to user email with reply to a previous mail?..

on 7/23/14, 7:02 AM 2,376 views

Openerp OpenChatter created messsage (mail.message) how to send to user email (mail.mail) with reply to a previous mail and which method to override?..

Using the below code First time created mail.message able to send user email.

Create method overrriden and  mail.message data send to mail.mail code:-

def create(self, cr, uid, vals, context=None):
        message_obj = self.pool.get('mail.message')        
        subtype_obj = self.pool.get('mail.message.subtype')
        mail_server_obj = self.pool.get('ir.mail_server')
        mail_mail_obj = self.pool.get('mail.mail')
        subtype_id = subtype_obj.search(cr, uid, [('name','=','CustomModu')])
        res_id = super(custom_module, self).create(cr, uid, vals, context=context)
        message_id = message_obj.search(cr, uid, [('subtype_id','=',subtype_id[0]),('res_id','=',res_id)])       
        for message_val in message_obj.browse(cr, uid, message_id):
            body = message_val.body
            subject = message_val.subject
        mail_server_ids = mail_server_obj.search(cr, uid, [], context=context)
        mail_vals = {'mail_message_id': message_id[0],
                     'mail_server_id': mail_server_ids and mail_server_ids[0],
                     'state': 'outgoing',
                     'email_from': 'from@email',
                     'email_to': 'to@email',
                     'body_html': body}
        mail_mail_id = mail_mail_obj.create(cr, uid, mail_vals, context=context)
        if mail_mail_id:
            mail_mail_obj.send(cr, uid, [mail_mail_id], context=context)
        return res_id

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 7/23/14, 7:02 AM
Seen: 2376 times
Last updated: 3/16/15, 8:10 AM