Skip to Content
Menu
This question has been flagged
1 Atsakyti
7267 Rodiniai

Hello all, 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.

Portretas
Atmesti
Autorius Best Answer

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.

Portretas
Atmesti
Related Posts Replies Rodiniai Veikla
1
kov. 22
3247
1
rugp. 23
1554
1
rugp. 22
5877
0
geg. 22
3404
3
gruod. 23
20008