首页 > 解决方案 > 仅在odoo11中隐藏特定模块中的“创建”按钮

问题描述

我想隐藏树视图标题中的创建和导入按钮我的 Odoo 版本是 odoo11

我的树视图的屏幕截图

我尝试在我的树视图标签中使用插create="false" edit="false"​​入,但它隐藏了所有按钮,我也尝试替换t-operation="after"tot-operation="replace"但它影响所有其他应用程序

<template xml:space="preserve">
        <t t-extend="ListView.buttons">
            <t  t-jquery="button.o_list_button_add" t-operation="replace">
                <button t-if="widget.modelName == 'hr.timeinout'" type="button" class="btn btn-primary btn-sm oe_refresh_button" accesskey="f">
                    Refresh List
                </button> 
            </t>
        </t>
</template>

我只想隐藏特定树视图中的“创建”和“导入”按钮谢谢

标签: odooodoo-11

解决方案


试试这个代码来删除创建按钮:

    <t t-extend="ListView.buttons">
        <!-- this will hide create button for model  'hr.timeinout' -->
        <t  t-jquery="button.o_list_button_add" t-operation="attributes">
            <attribute name="t-if">widget.modelName != 'hr.timeinout'</attribute>
        </t>

        <!-- this will add refresh button for model  'hr.timeinout' -->
        <t  t-jquery="div.o_list_buttons" t-operation="prepend">
            <button t-if="widget.modelName == 'hr.timeinout'" type="button" class="btn btn-primary oe_refresh_button" accesskey="f">
                Refresh List
            </button>
        </t>

    </t>

并删除此模型的导入按钮:

    <t t-extend="ImportView.import_button">
        <!-- this will remove button import for model  'hr.timeinout' -->
        <t  t-jquery="button.o_button_import" t-operation="attributes">
            <attribute name="t-if">widget.modelName != 'hr.timeinout'</attribute>
        </t>
    </t>

推荐阅读