How do I pass data to report_action() in Odoo 11 Windows Enterprise? (https://github.com/odoo/odoo/blob/11.0/odoo/addons/base/ir/ir_actions_report.py#L673 does not mention the data parameter)
I am using to report_action(); I added a button that prints my pdf template if I only pass the browse record parameter but if I try to pass some data with the data parameter I get a corrupted pdf that can not be opened with Adobe Reader; same template works fine without data (just the browse record).
This works:
@api.multi
def print_my_pdf_report(self, options):
return self.env.ref('my_module_name.my_report_id').report_action(self)
But this does not work:
@api.multi
def print_my_pdf_report(self, options):
# Some sample data
datas = {
'lines': [],
'report_name': 'My Report Name'
}
return self.env.ref('my_module_name.my_report_id').report_action(self, data=datas)
My sample template:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="my_sample_template">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="web.external_layout">
<div class="page">
<h2>Report title</h2>
<p>This object's name is
<span t-field="o.name"/>
</p>
</div>
</t>
</t>
</t>
</template>
</data>
</odoo>
Odoo Reporting Tips
1- https://goo.gl/tg2Zyp
2- https://goo.gl/KZEo8X