首页 > 解决方案 > Odoo 10:如何隐藏我的自定义模块的导入按钮?

问题描述

我创建了一个自定义模块,我想隐藏创建和导入按钮。直到现在我能够隐藏创建按钮,但我无法使用类似的代码隐藏我的导入按钮。下面是我的代码:

<?xml version="1.0" encoding="UTF-8"?>

<templates id="template" xml:space="preserve">

    <t t-extend="ListView.buttons">

           <t t-jquery="button.o_list_button_add" t-operation="replace">

                <t t-if="widget.model=='simcard.simcard'">

                    <button class="btn btn-sm btn-default sync_button" type="button">Sync</button>
                </t> 

           </t>

            <t t-jquery=".btn.btn-sm.btn-default.o_list_button_import" t-operation="replace">

                <t t-if="widget.model=='simcard.simcard'">


                </t>
            </t> 

    </t>

</templates>

上面的代码隐藏了 Create 按钮,但没有隐藏 Import 按钮。我可以在代码中更改哪些内容以隐藏“导入”按钮?

标签: xmlimportodoooncreate

解决方案


你可以像这样完成它:

<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
    <t t-extend="ListView.buttons">
        <t t-jquery="button.o_list_button_add" t-operation="before">
            <t t-if="widget.model=='simcard.simcard'">
                <t t-set="widget.options.addable" t-value="false"/>
                <t t-set="widget.options.import_enabled" t-value="false"/>
                <button class="btn btn-sm btn-default sync_button" type="button">Sync</button>
            </t>
        </t>
    </t>
</templates>

推荐阅读