3

ssnid と sinid を非表示のフィールドとして設定しましたが、どちらもまだビューに表示されています。XPath の場所に問題があるようです。

誰でも整理するのを手伝ってくれますか?

<?xml version="1.0"?>
<openerp>
    <data>
        <!-- 1st part of the sim_view start -->
        <record model="ir.ui.view" id="madulsima_plucker_form">
            <field name="name">madulsima.plucker.form</field>
            <field name="model">madulsima.plucker</field>
            <field name="inherit_id" ref="hr.view_employee_form" />
            <field name="type">form</field>
            <field name="arch" type="xml">
                <notebook position="inside">
                    <page string="Madulsima Plucker Fields">
                        <field name="reg_no" />
                        <field name="worker_name" />

                        <xpath expr="/form/notebook/page/group/field[@name='ssnid']"
                            position="attributes">
                            <attribute name="invisible">True</attribute>
                        </xpath>
                        <xpath expr="/form/notebook/page/group/field[@name='sinid']"
                            position="attributes">
                            <attribute name="invisible">True</attribute>
                        </xpath>

                    </page>
                </notebook>
            </field>
        </record>

        <record model="ir.actions.act_window" id="action_plucker_registration">
            <field name="name">Plucker Registration</field>
            <field name="res_model">madulsima.plucker</field>
            <field name="view_type">form</field>
            <field name="view_mode">form</field>
        </record>


        <menuitem id="menu_madulsima_plucker" name="Madulsima/Checkroll" />

        <menuitem id="menu_madulsima_plucker_registration" name="Plucker Registration"
            parent="menu_madulsima_plucker" action="action_plucker_registration" />
    </data>
</openerp>

コード全体をview.xmlに投稿しました

4

1 に答える 1

5

継承されたビューarchのフィールドのルート要素は、特別な属性に従って操作を実行できる親ビューの要素を識別するロケーターです。position

ロケータにはposition属性が必要で、次のいずれかになります。

  • 親ビューで単一の要素を見つけるための有効な XPath式を含む属性を持つ<xpath>要素。expr
  • 親ビューの有効なビュー要素。

親ビューにいくつかの変更を加えるために、継承されたビューは複数のルート要素を持つことができます。

いくつかのロケーターをネストしているため、例は正しくありません。xpath要素は要素内にありますpage。継承されたビューでは、要素と 2 つの要素の 3 つの要素にposition属性があることに注意してください。それらはすべてビュー アーキテクチャの最上位にある必要があります。次に例を示します。notebookxpath

       <field name="arch" type="xml">
            <notebook position="inside">
               <!-- ... elements you want to add inside the parent notebook -->
            </notebook>
            <xpath expr="/form/notebook/page/group/field[@name='ssnid']"
                   position="attributes">
                <attribute name="invisible">True</attribute>
            </xpath>
            <xpath expr="/form/notebook/page/group/field[@name='sinid']"
                   position="attributes">
                <attribute name="invisible">True</attribute>
            </xpath>
        </field>

PS: XPathに慣れていない場合は、このようなクイック リファレンスまたはチート シートをオンラインで探す必要があります。

于 2013-03-18T12:54:26.913 に答える