ODOO 10自定义报告pdf名称

问题描述 投票:0回答:2

我正在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的名称?怎么样?

谢谢。

odoo odoo-10
2个回答
0
投票

您可以这样操作,进入设置->技术->报告->报告,选择销售报告,

示例,报告报价/订单。然后打开报告并添加“(((object.name或'').replace('/','')+'。pdf')”到打印报告名称字段。

使用报价单/销售单打印进行检查。

谢谢


0
投票

是的,这可行,我在一些报告中使用它。但是,在我的自定义报告模块中,此字段已正确添加,但始终将xml报告定义中定义的“字符串”字段作为pdf名称。

© www.soinside.com 2019 - 2024. All rights reserved.