【发布时间】:2020-02-19 12:48:24
【问题描述】:
我正在 ODOO10 CE 中开发自定义报告,但在命名生成的 PDF 时遇到问题。它总是在报告定义中命名“字符串”字段。它会忽略 print_report_name 字段。
这是报告定义:
<report
id="action_report_as"
model="report_as"
string="Report AS_EE"
report_type="qweb-pdf"
name="report_as_ee.report_as"
paperformat="report.vertical_1"
/>
<record
id="action_report_as"
model="ir.actions.report.xml">
<field name="print_report_name">mycorrectreportname.pdf</field>
</record>
这是.py:
class ReportAs(models.AbstractModel):
_name = 'report.report_as_ee.report_as'
@api.model
def render_html(self, docids, data=None):
self.model = self.env.context.get('active_model')
docs = self.env[self.model].browse(self.env.context.get('active_id'))
as_records = []
#
# code that puts records in as_records array
#
docargs = {
'doc_ids': self.ids,
'doc_model': self.model,
'docs': docs,
'time': time,
'as': as_records
}
return self.env['report'].render('report_as_ee.report_as', docargs)
也许我需要从 .py 中输入名称?怎么样?
谢谢。
【问题讨论】: