Enabling language translation in reports

To enable translations for a report, they need to be called from a template, using a <t t-call> element with a t-lang attribute.

The t-lang attribute should evaluate to a language code, such as es or en_US. It needs the name of the field where the language to use can be found.

One way to do this is by using the current user's language. For this, we define an outer translation report that calls a report to translate, setting the source for the language in the t-lang attribute:

<report id="action_todo_task_report_translated" string="Translated To-do Tasks" model="todo.task" report_type="qweb-pdf" name="todo_stage.report_todo_task_translated" paperformat="paperformat_euro_landscape" /> <template id="report_todo_task_translated"> ...

Get Odoo 11 Development Essentials - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.