Odoo 针对原视图 继承修改字段位置和属性

源代码purchase/views/purchase_views

<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属性改为invisible=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>

针对search视图继承增加分组见此篇

猜你喜欢

转载自blog.csdn.net/iuv_li/article/details/128252514