i'm trying to override a button which using type="action".
Original Button:
<button name="%(sale.action_view_sale_advance_payment_inv)d" string="Create Invoice"
type="action" context="{'default_advance_payment_method': 'percentage'}" data-hotkey="q"
attrs="{'invisible': ['|',('invoice_status', '!=', 'no'), ('state', '!=', 'sale')]}"/>
I'm trying to inherit it with usual way which is use @name= .. like this:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="sale_order_view_form_create_contract_button" model="ir.ui.view" style="color:#e8bf6a;">>
<field name="name">sale_order_view_form_create_contract_button</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="priority" eval="100"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='%(sale.action_view_sale_advance_payment_inv)d']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
</field>
</record>
</odoo>
Unfortunately, It doesn't seem to work.
Please help, thanks you.
CodePudding user response:
I've found the answer:
It use name as usual:
<xpath expr="//button[@name='%(sale.action_view_sale_advance_payment_inv)d']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
But in this view_order_form, odoo have defined 2 button which exactly the same as each other, so i've set index for it to make this work, such as i want to remove 2nd button, then i must add [2] to it, so it will look like this:
<!-- remove 2nd button "Create Invoice" in view_order_form -->
<xpath expr="//button[@name='%(sale.action_view_sale_advance_payment_inv)d'][2]" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
Thanks you all for reading.