Odoo Help

Welcome!

This community 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.

0

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

By
Prakash
on 7/23/14, 7:02 AM 1,722 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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

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