如何移除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
相关产品推荐
相关产品推荐

