Community mailing list archives

Re: Render a html field as qweb

Paul Catinean
- 01/22/2016 07:08:08
Hello Yannik,

Glad to have you among us

I'm not sure if this is the best way to do it but it works for emails that need parsing variables and translation before sending

Using QWeb alone should be possible too but for messages like you mentioned I think the mako syntax is much easier

1. Firstly import the mako template environment and openerp tools

from openerp.addons.email_template.email_template import mako_template_env
from openerp import tools

2. Then you use the mako template environment to render and translate your content using mako syntax:


You can place the final result in a variable or a method and call from qweb using t-esc (which is safer and does not need to do anything except output the result)

You can also find examples of mako templates in the standard Email templates

Hope this helps


On Fri, Jan 22, 2016 at 11:36 AM, Yannik Lieblinger <> wrote:

Hi all,

I try to build an new module for our sales order and invoice reports.

The Module should add custom text with variables like to the end of the report. I have create an Class with an text field which should hold the custom qweb subtemplates.

If I call the field via t-raw all looks great but no variables getting rendered and they are printed as text only. I'm new to odoo, so I don't really understand the python print workflow. But is there a possibility to render my templates from the text field with variables which are available in the sale order document?

Regards Yannik

Post to: