【问题标题】:ODOO 10 custom report pdf nameODOO 10 自定义报告 pdf 名称
【发布时间】: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 中输入名称?怎么样?

谢谢。

【问题讨论】:

    标签: odoo odoo-10


    【解决方案1】:

    你可以这样做,进入设置->技术->报告->报告,选择销售报告,

    例如,报告报价/订单。然后打开报告并添加 "((object.name or '').replace('/','')+'.pdf')" this to field Printed Report Name.

    检查报价/销售订单打印。

    谢谢

    【讨论】:

    • 是的,这很有效,我在一些报告中使用它。但在我的自定义报告模块中,此字段已正确添加,但始终将 xml 报告定义中定义的“字符串”字段作为 pdf 名称。
    • 你能更新你所面对的图像吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多