Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
1 Antworten
7277 Ansichten

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.

Avatar
Verwerfen
Autor Beste Antwort

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.

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
1
März 22
3255
1
Aug. 23
1554
1
Aug. 22
5882
0
Mai 22
3410
3
Dez. 23
20009