You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何移除Odoo 14中qweb-html类型报表的默认打印按钮

问题描述

我在Odoo 14中创建了类型为(qweb-html)的报表,想要移除该报表的默认打印按钮,如下图所示:
报表打印按钮示意图

解决方案

方法1:继承系统打印按钮模板实现(推荐,仅对指定报表生效)

  • 第一步:创建继承自系统report.webclient_print_button模板的自定义QWeb视图,参考代码如下,替换代码中你的模块名.你的报表xml_id为你实际的报表标识:
<odoo>
    <data>
        <template id="hide_custom_report_print_btn" inherit_id="report.webclient_print_button">
            <!-- 隐藏目标报表的打印按钮 -->
            <xpath expr="//button[contains(@class, 'print_report')]" position="attributes">
                <attribute name="t-att-style"> "'display: none !important;'" if report_name == '你的模块名.你的报表xml_id' else '' </attribute>
            </xpath>
        </template>
    </data>
</odoo>
  • 第二步:将上述视图文件添加到自定义模块的__manifest__.py的data列表中,升级自定义模块后刷新页面即可生效。

方法2:报表模板内嵌CSS实现

如果只需快速生效,可直接在你自定义的QWeb报表模板的头部加入如下样式代码:

<style>
    .o_report_buttons .print_report, .o_control_panel .o_print_report {
        display: none !important;
    }
</style>

保存后升级模块即可看到效果。

内容的提问来源于stack exchange,提问作者Shilal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.02 01:18:02