Odoo は、元のビュー継承のフィールドの位置と属性を変更します。

ソースコードの購入/ビュー/購入_ビュー

<record id="purchase_order_tree" model="ir.ui.view">
            <field name="name">purchase.order.tree</field>
            <field name="model">purchase.order</field>
            <field name="arch" type="xml">
                <tree decoration-bf="message_unread==True" decoration-muted="state=='cancel'" decoration-info="state in ('wait','confirmed')" string="Purchase Order">
                    <field name="message_unread" invisible="1"/>
                    <field name="name" string="Reference"/>
                    <field name="date_order" />
                    <field name="partner_id"/>
                    <field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>
                    <field name="date_planned" invisible="context.get('quotation_only', False)"/>
                    <field name="origin"/>
                    <field name="amount_untaxed" sum="Total Untaxed amount" string="Untaxed" widget="monetary"/>
                    <field name="amount_total" sum="Total amount" widget="monetary"/>
                    <field name="currency_id" invisible="1"/>
                    <field name="state"/>
                    <field name="invoice_status" invisible="not context.get('show_purchase', False)"/>
                </tree>
            </field>
        </record>

これでビューの継承が行われ、company_id 属性を非表示=1 に変更します
。次に必要となるのは、company_id をビューの最後に置き、再表示することです。

- まずフィールドを空白に置き換えます。
- 次に、指定された位置にフィールドと必要な属性を挿入します。

    <record id="inherit_purchase_order_tree" model="ir.ui.view">
        <field name="name">inherit purchase_order_tree</field>
        <field name="model">purchase.order</field>
        <field name="inherit_id" ref="purchase.purchase_order_tree"/>
        <field name="arch" type="xml">
            <xpath expr="//tree/field[@name='company_id']" position="replace"/>
            <xpath expr="//tree/field[@name='state']" position="after">
                <field name="company_id" groups="base.group_multi_company"/>
            </xpath>
        </field>
    </record>

検索ビュー継承のためのグループ化の追加については、この記事を参照してください。

おすすめ

転載: blog.csdn.net/iuv_li/article/details/128252514