Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
7378 มุมมอง

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.

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

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.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
มี.ค. 22
3361
1
ส.ค. 23
1636
1
ส.ค. 22
6040
0
พ.ค. 22
3535
How to connect button with function? แก้ไขแล้ว
3
ธ.ค. 23
20143