Odoo Help


Template mail Odoo Error

on 11/5/16, 8:17 AM 428 views


I created a module to send a scheduled daily mail.

the mail is successfully sent.

But In mail, body does not appear correctly.

this is my code and the output


def send_crm_report(self, cr, uid, ids=None, context=None):

        message_obj = self.pool.get('mail.message') mail_mail = self.pool.get('mail.mail') mail_ids = [] today = datetime.now().strftime('%Y-%m-%d 00:00:00') par_id = message_obj.search(cr, uid, [('date', '>', today), ('model', '=', 'crm.lead') ]) if par_id:


                email_from = "crm@exemple.com" name = "Name" subject = "CRM Report" mail_ids.append(mail_mail.create(cr, uid, { 'email_to': "emna.hidri@gmail.com", 'subject': subject, 'body_html': '<table><tbody><tr><th style="width:135px">Vendeur</th><th style="width: 85px;">opportunite</td><th style="width: 125px;">Description</th></tr> % for row in message_obj.browse(cr, uid, par_id): <tr><td> ${row.author_id.name} </td><td style="text-align: center;"> ${row.subject or ''} </td><td> ${row.body or ''} </td></tr> %endfor <tbody><table>'

                    }, context=context)) mail_mail.send(cr, uid, mail_ids, context=context) except Exception, e:

                print "Exception", e return None


Vendeur opportunite Description

% for row in message_obj.browse(cr, uid, par_id):

${row.author_id.name} ${row.subject or } ${row.body or }%endfor

Thanks for reply

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

1 follower(s)


Asked: 11/5/16, 8:17 AM
Seen: 428 times
Last updated: 11/5/16, 9:53 AM