error while launching qweb report from python

梦想与她 提交于 2021-01-27 11:50:38

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!