且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从 python 启动 qweb 报告时出错

更新时间:2022-11-30 16:39:37

确保 report_action_name 是报告的 record_id .例如:

蟒蛇

self.env.ref('module_name.record_id').report_action(self, data=data, config=False)

xml

 <field 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></记录>

报告 XML

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

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>