2016-10-21 21 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を使う必要があります。

もう1つの良い例は、フォームビューのnameフィールドの後ろに新しいsale.order.lineフィールドを設定しています。 (この例では)sale.ordernameフィールドの後ろに新しいフィールドを設定してみてください可能性があなたの方法を使用して

<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> 

: フォームビューは、このようなものです。 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] 

・ホープ助けてください

関連する問題