2

Odoo 9 コミュニティ バージョンを使用しています。

販売注文フォームには次のボタンがあります。

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

上記のコードでは、最初のボタンのみを非表示/影響します。

質問:

両方の販売確認ボタンを非表示にする方法は?

4

3 に答える 3

5

xpath を使用しないメカニズムは、最初のヒットにのみ影響します。そのため、ここで xpath を使用する必要があります。

もう 1 つの良い例 (Odoo 9 ではもうないかもしれません) は、フォーム ビューのフィールドsale.order.lineの後ろに新しいフィールドを設定することです。フォーム ビューは次のようなものです。namesale.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.order name(この例では)。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>

あなたの質問に直接答えるには(編集):

<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
于 2016-10-21T07:13:22.543 に答える
0

xpathを使用できます...

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

xpath ...

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

それが役に立てば幸い

于 2016-12-24T16:12:05.990 に答える