ODOO
reports
we can let the user choose the language for report with out change his language as bellow
- define languages field as bellow
report_language = fields.Many2one('res.lang','Report Language', required=True)
- define the external template in which we call the language that entered by the user as bellow
<template id="report_main_temp">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="doc">
<t t-call="certifications.student_file_template" t-lang="doc.certification_language.code"/>
</t>
</t>
</template>
<t t-call="report.html_container">
<t t-foreach="docs" t-as="doc">
<t t-call="certifications.student_file_template" t-lang="doc.certification_language.code"/>
</t>
</t>
</template>
- the we will add internal template in which we will define report body for each language we installed in our system
EG : for English language
<template id="report_file_template">
<!-- <t t-foreach="docs" t-as="o" > -->
<t t-set="doc" t-value="doc.with_context({'lang':doc.report_language.code})" />
<!-- <t t-foreach="docs" t-as="o" > -->
<t t-set="doc" t-value="doc.with_context({'lang':doc.report_language.code})" />
<t t-if="line(data)[0]['c_language'].code == 'en_US'">
""" the report body in English language """
</t>
</t>
</template>
No comments:
Post a Comment