Search code examples
xmlimportodoooncreate

Odoo 10 : How to hide import button for my custom Module?


I created a custom module and I wanted to hide Create and Import button.Till now I am able to hide Create button but I cant hide my import button using the similar code. Below is my code :

<?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>

Above code hides the Create button but not the Import button. What can i change in the code to hide the Import button?


Solution

  • You could get it done like this:

    <?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>