Make a Qweb report translatable in Odoo v8

If you want the QWeb report that you create in Odoo to be printed in different languages in context of the partner’s or user’s language then you need to use the translate_doc function. In such case, you need to create two templates. First, designed in the default language and it is called translatable template, and the second one where you will call translate_doc function and it is named as main template. The main template actually returns translatable template translated in a given language.

For Example, if you have Sale Order report that is always printed in English and now you need to add an option to be printed in the customer’s language. You would need to add one more template that now will be the main report and existing report will become translatable report:

<template id="sale_order_report_main">
    <t t-call="report.html_container">
        <t t-foreach="doc_ids" t-as="doc_id">
            <t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang', 'sale.sale_order_report')"/>

Additionally, you will need to update report’s action definition to call the main report. Also, you need to provide translation for the report for the languages that will be used in the system.

You can find more detailed info about this also in the official Odoo documentation

Leave a Reply

Your email address will not be published. Required fields are marked *