See example in report_invoice.xml:
<template id="report_invoice">
<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', 'account.report_invoice_document')"/>
</t>
</t>
</template>
translate_doc() - is a helper used when a report should be translated into a specific lang
A generic report use the default rendering context. If you want a new rendering context containing anything you want to process your data Odoo AbstractModel, a custom module is needed, like this:
from openerp import api, models
class ParticularReport(models.AbstractModel):
_name = 'report.<<module.reportname>>'
@api.multi
def render_html(self, data=None):
report_obj = self.env['report']
report = report_obj._get_report_from_name('<<module.reportname>>')
docargs = {
'doc_ids': self._ids,
'doc_model': report.model,
'docs': self,
}
ctx = dict(self._context)
ctx['translatable'] = True
report_obj = report_obj.with_context(ctx)
return report_obj.render('<<module.reportname>>', docargs)
Hi zbik, thank you for your answer. How can I force a language for translate_doc though? I would like for instance to force the document to be produced always with the German (de_DE) locale. Any parameter I pass as the third parameter to translate_doc is used as an accessor to a field of the object doc. I see in the coding of translate_doc that it checks for a translatable value in the context (if false, apparently the language can be forced), but I do not understand how this value in the context could be set.. Thank you and regards, Giulio