Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged

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

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
srp 25
1558
1
kvě 25
1279
2
kvě 25
1431
0
dub 25
1131
1
bře 25
1625