问题
I'm upgrading a module from odoo v10 to odoo v11. It is founded that the get_action is replaced with report_action.
so I used the code as follows
self.env.ref('report_action_name').report_action(self, data=data, config=False)
but it gives me error AttributeError: 'ir.ui.view' object has no attribute 'report_action' Thanks in advance
回答1:
Make sure that report_action_name
is the record_id
of the report .
Eg:
Python
self.env.ref('module_name.record_id').report_action(self, data=data, config=False)
xml
<record id="record_id" model="ir.actions.report">
<field name="name">Name</field>
<field name="model">Model</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">module_name.report_template_id</field>
</record>
Report XML
<template id="report_template_id">
<Your code>
</template>
来源:https://stackoverflow.com/questions/50906043/error-while-launching-qweb-report-from-python