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

I am trying to replace a button in a sales order form to add a simple confirmation message using the confirm tag. My custom view is not replacing the button however and I am not exactly sure why and I am not super familiar with view inheritance. It does appear in the list of views inside Odoo and is successfully inheriting the sales view order form.


The custom view

<odoo>
    <template id="sales_form_with_confirm" name="Sales Form with Confirm" inherit_id="sale.view_order_form">
        <xpath expr="//button[@name='action_cancel']" position="replace">
            <button name="action_cancel" states="draft,sent,sale" type="object" string="Cancel" confirm="Are you sure?"></button>
        </xpath>
    </template>
</odoo>


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

The opted way is not the right/correct way to inherit a view, you can inherit view like this,


<record id="sale_order_inherit" model="ir.ui.view">
<field name="name">sale.order.inherit</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
</field>
</record>

and for making changes to the cancel button,


<record id="sale_order_inherit" model="ir.ui.view">
<field name="name">sale.order.inherit</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<button name="action_cancel" position="attributes">
<attribute name="confirm">Are you sure you want to cancel this?</attribute>
</button>
</field>
</record>


See More at here: https://www.youtube.com/watch?v=z1Tx7EGkPy0&list=PLqRRLx0cl0hoJhjFWkFYowveq2Zn55dhM&index=11

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด
Try with below code:-
<xpath expr="//header/button[@name='action_cancel']" position="replace">
<button name="action_cancel" states="draft,sent,sale" type="object" string="Cancel" confirm="Are you sure?"></button>
</xpath>
 
อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
How to modify a qweb template? แก้ไขแล้ว
2
ธ.ค. 22
22860
View inheritance แก้ไขแล้ว
1
มี.ค. 20
3460
Qweb Inheritance แก้ไขแล้ว
3
พ.ย. 19
7690
12
ธ.ค. 18
34773
1
ก.ค. 16
7077