-1

I want to remove Create and Import button in my module and replace it with Sync button.I tried below 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="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>

This adds 'false' button next to my Sync button. Then i tried below solution which doesnt remove the Create button but removes the Import button :

    <?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="after">
                <t t-if="widget.model=='simcard_piavita.simcard_piavita'">
             <button class="btn btn-sm btn-default sync_button" type="button">Sync</button>
                    <t t-set="widget.options.addable" t-value="false"/>

                    <t t-set="widget.options.import_enabled" t-value="false"/>

                </t>
            </t>
        </t>
    </templates>

Then i tried below solution :

<?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_piavita.simcard_piavita'">
         <button class="btn btn-sm btn-default sync_button" type="button">Sync</button>
                <t t-set="widget.options.addable" t-value="false"/>

                <t t-set="widget.options.import_enabled" t-value="false"/>

            </t>
        </t>
    </t>
</templates> 

It removes the Create button from other installed modules as well. Is there a perfect way to remove the Create button and keep the Sync button in my module?

Anudocs
  • 686
  • 1
  • 13
  • 54

1 Answers1

0

If you want to remove create button in one view then add attribute create="false"

<form string="Picking" create="false" sync="true">

If you want to add sync button in one view then you can also relay on an attribute

<templates id="template" xml:space="preserve">
    <t t-jquery="button.o_form_button_save" t-operation="after">
        <button t-if="widget.is_action_enabled('sync')" type="button" class="btn btn-primary btn-sm o_form_button_save" accesskey="s">
        Sync
        </button>
    </t>
</templates>