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"> <t t-call="todo_stage.report_todo_task_template" t-lang="user.lang" /> </template>
In some cases, we may need each record to be rendered in a...