odoo 按钮打印pdf报表

odoo打印一般是在动作里面进行的

所以此方法可用自定义按钮进行打印

xml 复制代码
<template id="report_sale_line_packing_template">
xxx
</template>
    <template id="report_sale_line_packing">
        <t t-call="web.basic_layout">
            <t t-foreach="docs" t-as="o">
                <div class="page">
                    <t t-call="sale_reports.report_sale_line_packing_template"/>
                </div>
            </t>
        </t>
    </template>
<record id="action_report_sale_line_list" model="ir.actions.report">
        <field name="name">销售明细</field>
        <field name="model">sale.order.line</field>
        <field name="report_type">qweb-pdf</field>
        <field name="report_name">sale_reports.report_sale_line_packing</field>
        <field name="report_file">sale_reports.report_sale_line_packing</field>
        <field name="print_report_name">'销售明细%s' %(object.name or '')</field>
        <field name="binding_model_id" ref="model_sale_order_line"/>
        <field name="binding_type">report</field>
    </record>
python 复制代码
    def action_report_data(self):
        url = '%s/report/pdf/sale_reports.report_sale_line_packing/%s' % (self.get_base_url(), self.id)
        return {
            'type': 'ir.actions.act_url',
            'name': "销售明细报表",
            'target': 'new',
            'url': url,
            'res_id': self.id,
        }
相关推荐
C_心欲无痕1 小时前
前端如何实现 [记住密码] 功能
前端
苏宸啊6 小时前
Linux权限
linux·运维·服务器
xqhoj7 小时前
Linux——make、makefile
linux·运维·服务器
qq_316837757 小时前
uni.chooseMedia 读取base64 或 二进制
开发语言·前端·javascript
张童瑶7 小时前
Linux 在线安装编译Python3.11
linux·运维·python3.11
Shi_haoliu7 小时前
SolidTime 在 Rocky Linux 9.5 上的完整部署流程
linux·运维·nginx·postgresql·vue·php·laravel
Zoey的笔记本7 小时前
2026告别僵化工作流:支持自定义字段的看板工具选型与部署指南
大数据·前端·数据库
小二·8 小时前
Python Web 开发进阶实战:混沌工程初探 —— 主动注入故障,构建高韧性系统
开发语言·前端·python
Lkygo8 小时前
LlamaIndex使用指南
linux·开发语言·python·llama
gis开发8 小时前
【无标题】
java·前端·javascript