2
votes

I am using Odoo 10e. In tree view or in form view for my particular model, i want to change the create button text to Add New User. How can we achieve this? I tried to use Xpath for this, but as far as i know Xpath is use to inherit from a view and add something in the view not to change the item in the parent view

2
Have you check something like this: <xpath expr="..." > <button name="your_target_button_name"> <attribute name="label">Add New User</attribute> </button> </xpath>Hammad Qureshi

2 Answers

1
votes

Create one xml file and write this below code in it.

For listview and formview it will change the name of create button as per your custom string.

Add this xml file path to qweb section in manifest file.

<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">

<t t-extend="ListView.buttons">
    <t t-jquery=".o_list_button_add" t-operation="replace">    
        <button type="button" class="btn btn-primary btn-sm o_list_button_add" accesskey="c">
            <t t-if="widget.model === 'sale.order'">
                Your String
            </t>
            <t t-if="widget.model !== 'sale.order'">
                <t t-esc="widget.options.addable"/>
            </t>
        </button>
    </t>
</t>

<t t-extend="FormView.buttons">
    <t t-jquery=".o_form_button_create" t-operation="replace">        
        <button t-if="widget.is_action_enabled('create')" type="button"
                class="btn btn-default btn-sm o_form_button_create" accesskey="c">
            <t t-if="widget.model === 'sale.order'">
                 Your String
            </t>
            <t t-if="widget.model !== 'sale.order'">
                 Create
            </t>
        </button>
     </t>
</t>
</templates>

I hope this answer will help you.

1
votes

Simply just xpath to that button. Then give position replace and change the string to Add New User from Create. Try the code like this. But remember the name of the button will be as it is. Thanks

        <xpath expr="//button[@name='action_set_create']" position="replace">
        <button name="action_set_create" string="Add New User"/>
    </xpath>