I would like to create email template in odoo. My code is as follows,
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="room_request_approval" model="email.template">
<field name="name">Approval Notification</field>
<field name="email_from">${object.users_company.email}</field>
<field name="subject">Room request approved</field>
<field name="email_to" >${object.assignee.email}</field>
<field name="auto_delete" eval="True"/>
<field name="model_id" ref="model_request_room"/>
<field name="body_html"><![CDATA[
<html>
<head>
<title>Room Request Approved</title>
<style>
span.oe_mail_footer_access {
display:block;
text-align:center;
color:grey;
}
</style>
</head>
<body>
<p>Hiii</p>
</body>
</html>
]]>
</field>
</record>
It is giving error as follows, ParseError: "email.template" while parsing file
Have you checked if the problem is inside the body_html
field? Try with something simpler, like the following, and also add safe to the emails:
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="room_request_approval" model="email.template">
<field name="name">Approval Notification</field>
<field name="email_from">${(object.users_company.email or '')|safe}</field>
<field name="subject">Room request approved</field>
<field name="email_to" >${(object.assignee.email or '')|safe}</field>
<field name="auto_delete" eval="True"/>
<field name="model_id" ref="model_request_room"/>
<field name="body_html"><![CDATA[
<p>Hello!</p>]]></field>
</record>
</data>
</openerp>
I guess your model is named request.room
and it has two Many2one
fields named users_company
and assignee
, hasn't it?
And in Python code, you should have something like this to send the mail:
request_room_recordset = self.env['request.room'].search(
whatever_domain).ensure_one()
et_pool = self.pool.get('email.template')
mail_sent = et_pool.send_mail(
self.env.cr, 1, template.id, request_room_recordset.id,
force_send=True, context=self.env.context)