odoo报告(QWEB)详解,以打印下拉菜单为例

1、安装wkhtmltopdf(报告是以PDF文件展现)在这里插入图片描述
2、ODOO中找到相关模型对应的报告(以account.invoice为例)
在这里插入图片描述

2、继承修改QWEB模板

<?xml version="1.0" encoding="utf-8"?>
<odoo>

       <template id="report_invoice_document_with_payments1" inherit_id="account.report_invoice_document" >
            <xpath expr="//div[@name='invoice_date']" position="after">

                        <div class="col-auto mw-100 mb-2" t-if="o.bumen" name='部门'>
                            <strong>部门:</strong>
                            <p class="m-0" t-field="o.bumen"/>
                        </div>
                        <div class="col-auto mw-100 mb-2" t-if="o.invoice_type" name='发票类型'>
                            <strong>发票类别:</strong>
                            <p class="m-0" t-field="o.invoice_type"/>
                        </div>
                        <div class="col-auto mw-100 mb-2" t-if="o.lyr" name="经办人">
                            <strong>录入人:</strong>
                            <p class="m-0" t-field="o.lyr"/>
                        </div>

            </xpath>
        </template>


4、xml文件里的挂载
            <!-- QWeb Reports -->
        <report
            id="account_invoices"
            model="account.invoice"
            string="发票/账单"
            report_type="qweb-pdf"
            name="account.report_invoice_with_payments"
            file="account.report_invoice_with_payments"
            attachment="(object.state in ('open','in_payment','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')"
            print_report_name="(object._get_report_base_filename())"
            groups="account.group_account_invoice"
        />

        <report
            id="account_invoices_without_payment"
            model="account.invoice"
            string="Invoices without Payment"
            report_type="qweb-pdf"
            name="account.report_invoice"
            file="account.report_invoice"
            attachment="(object.state in ('open','in_payment','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')"
            print_report_name="(object._get_report_base_filename())"
        />

</odoo>

5、效果:
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值