Odoo 8 Qweb Wizard Report in Partner Language
Odoo 8
Partner Ledger Report Translation Example
1. Add Language field on wizard/account_report_partner_ledger.py
'lang_id' : fields.many2one('res.lang', 'Language)
2. Add Language field on wizard/account_report_partner_ledger_view.xml
<field name="lang_id"/>
3. Add field in data['form'] of wizard/account_report_partner_ledger.py/_print_report method
data['form'].update(self.read(cr, uid, ids, ['initial_balance', 'filter', 'page_split', 'amount_currency', 'lang_id'])[0])
4. Create the translation template in views/report_partnerledger.xml
<template id="report_partnerledger_translate">
<t t-call="report.html_container">
<t t-foreach="doc_ids" t-as="doc_id">
<t t-raw="translate_doc(doc_id, doc_model, 'lang_id.code', 'account.report_partnerledger')"/>
</t>
</t>
</template>
5. Create report registration in account_report.xml
<report
id="report_partnerledger_translate_reg"
string="Partner Ledger"
model="account.partner.ledger"
report_type="qweb-pdf"
file="account.report_partnerledger_translate"
name="account.report_partnerledger_translate"
/>
6. Add the template class in report/account_partner_ledger.py
class report_partnerledger_translate(osv.AbstractModel):
_name = 'report.account.report_partnerledger_translate'
_inherit = 'report.abstract_report'
_template = 'account.report_partnerledger_translate'
_wrapped_report_class = third_party_ledger
7. Return the report template report from wizard/account_report_partner_ledger.py/_print_report method
return self.pool['report'].get_action(cr, uid, [], 'account.report_partnerledger_translate', data=data, context=context)