콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
3887 화면

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>
 
아바타
취소
관련 게시물 답글 화면 활동
2
12월 22
22464
View inheritance 해결 완료
1
3월 20
3076
Qweb Inheritance 해결 완료
3
11월 19
7312
12
12월 18
34213
1
7월 16
6568