Tuesday, July 30, 2019

How to make user choose the language of report

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>  
  • 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-if="line(data)[0]['c_language'].code == 'en_US'">
""" the report body in English language """
</t>
</t>
</template>

No comments:

Post a Comment

Odoo Invoice Qr code issues

There are two main issues must of us facing with the QR code in Odoo invoice & these issues are 1/ QR code displayed as broken image w...