<?xml version="1.0" encoding="utf-8" ?>
<odoo>
    <record id="purchase_order_form" model="ir.ui.view">
        <field name="model">purchase.order</field>
        <field name="inherit_id" ref="purchase.purchase_order_form" />
        <field name="arch" type="xml">
            <field name="partner_id" position="after">
                <field name="order_type" required="True" />
            </field>
        </field>
    </record>
    <record id="purchase_order_tree" model="ir.ui.view">
        <field name="model">purchase.order</field>
        <field name="inherit_id" ref="purchase.purchase_order_tree" />
        <field name="arch" type="xml">
            <field name="state" position="before">
                <field
                    name="order_type"
                    invisible="context.get('group_by') == 'order_type'"
                />
            </field>
        </field>
    </record>
    <record id="view_purchase_order_filter" model="ir.ui.view">
        <field name="model">purchase.order</field>
        <field name="inherit_id" ref="purchase.view_purchase_order_filter" />
        <field name="arch" type="xml">
            <field name="partner_id" position="after">
                <field name="order_type" />
            </field>
            <group position="inside">
                <filter
                    string="Type"
                    name="order_type"
                    domain="[]"
                    context="{'group_by': 'order_type'}"
                />
            </group>
        </field>
    </record>
</odoo>
