2016-10-21 1 views
1

나는 Odoo 9 커뮤니티 버전을 사용하고 있습니다. 판매 주문 양식에 Odoo 9의 판매 주문 양식보기에서 "Confirm Sale"버튼을 숨기기

는 버튼을 다음과 같은있다 : 내가보기에서 모두 버튼을 숨길려고

<button name="action_confirm" states="sent" string="Confirm Sale" class="btn-primary" type="object" context="{'show_sale': True}"/> 
<button name="action_confirm" states="draft" string="Confirm Sale" type="object" context="{'show_sale': True}"/> 

. 그래서 나는 다음의 코드를 시도했다. 나는 또한 속성 다음 시도

<record model="ir.ui.view" id="hide_so_confirm_button_form"> 
    <field name="name">hide.so.confirm.button.form</field> 
    <field name="model">sale.order</field> 
    <field name="inherit_id" ref="sale.view_order_form"/> 
    <field name="arch" type="xml"> 
     <button name="action_confirm" position="attributes"> 
      <attribute name="invisible">1</attribute> 
     </button> 
    </field> 
</record> 

: 위의 코드와

<attribute name="states"></attribute> 

, 그것은 단지 숨기기/첫 번째 버튼에 영향을 미칠 것.

질문 :

방법 모두 확인 판매 버튼을 숨길?

답변

3

xpath가없는 메커니즘은 첫 번째 히트에만 영향을줍니다. 이것이 xpath를 사용해야하는 이유입니다.

또 다른 좋은 예는 (더 이상 Odoo 9가 아닐 수도 있음) name 필드 뒤의 sale.order.line 필드를 sale.order 양식보기에 새로 설정하는 것입니다. 양식보기이 같은 것입니다 :

<form> 
    <field name="name" /> <!-- sale.order name field --> 
    <!-- other fields --> 
    <field name="order_line"> 
     <form> <!-- embedded sale.order.line form view --> 
      <field name="name" /> 
      <!-- other fields --> 
     </form> 
     <tree> <!-- embedded sale.order.line tree view --> 
      <field name="name" /> 
      <!-- other fields --> 
     </tree> 
    </field> 
<form> 

(이 예에서) sale.ordername 필드 뒤에 새 필드를 설정하려고 할 수있는 방법을 사용. xpath를 사용하면 목표를 달성 할 수 있습니다.

<xpath expr="//form//tree//field[@name='name']" position="after"> 
    <field name="new_field" /> 
</xpath> 
<xpath expr="//form//form//field[@name='name']" position="after"> 
    <field name="new_field" /> 
</xpath> 

그래서 직접 귀하의 질문에 대답하기 (EDIT) :

<xpath expr="//button[@name='action_confirm' and @states='sent']" position="attributes"> 
    <attribute name="states" /> <!-- delete states attribute, it's influencing invisible behaviour --> 
    <attribute name="invisible">1</attribute> 
</xpath 
<xpath expr="//button[@name='action_confirm' and @states='draft']" position="attributes"> 
    <attribute name="states" /> <!-- delete states attribute, it's influencing invisible behaviour --> 
    <attribute name="invisible">1</attribute> 
</xpath 
-1

당신이 XPath를 사용할 수 있습니다 ...

button[@name='action_confirm'][1] 

XPath는 ...

button[@name='action_confirm'][2] 

희망 도움이

관련 문제