<?xml version="1.0" encoding="utf-8" ?>
<odoo>
    <record id="view_purchase_request_tree" model="ir.ui.view">
        <field name="name">view_purchase_request_tree</field>
        <field name="model">purchase.request</field>
        <field name="inherit_id" ref="purchase_request.view_purchase_request_tree" />
        <field name="arch" type="xml">
            <field name="requested_by" position="after">
                <field name="department_id" />
            </field>
        </field>
    </record>
    <record id="view_purchase_request_form" model="ir.ui.view">
        <field name="name">view_purchase_request_form</field>
        <field name="model">purchase.request</field>
        <field name="inherit_id" ref="purchase_request.view_purchase_request_form" />
        <field name="arch" type="xml">
            <field name="requested_by" position="after">
                <field
                    name="department_id"
                    attrs="{'readonly': [('state', '!=', 'draft')]}"
                />
            </field>
        </field>
    </record>
    <record id="view_purchase_request_search" model="ir.ui.view">
        <field name="name">view_purchase_request_search</field>
        <field name="model">purchase.request</field>
        <field name="inherit_id" ref="purchase_request.view_purchase_request_search" />
        <field name="arch" type="xml">
            <xpath expr="//group[1]" position="inside">
                <filter
                    name="group_department"
                    string="Department"
                    context="{'group_by':'department_id'}"
                />
            </xpath>
            <field name="requested_by" position="after">
                <field name="department_id" />
            </field>
        </field>
    </record>
    <record id="purchase_request_line_tree" model="ir.ui.view">
        <field name="name">purchase_request_line_tree</field>
        <field name="model">purchase.request.line</field>
        <field name="inherit_id" ref="purchase_request.purchase_request_line_tree" />
        <field name="arch" type="xml">
            <field name="requested_by" position="after">
                <field name="department_id" />
            </field>
        </field>
    </record>
    <record id="purchase_request_line_form" model="ir.ui.view">
        <field name="name">view_purchase_request_line_form</field>
        <field name="model">purchase.request.line</field>
        <field name="inherit_id" ref="purchase_request.purchase_request_line_form" />
        <field name="arch" type="xml">
            <field name="requested_by" position="after">
                <field
                    name="department_id"
                    attrs="{'readonly': [('request_state', '!=', 'draft')]}"
                />
            </field>
        </field>
    </record>
    <record id="purchase_request_line_search" model="ir.ui.view">
        <field name="name">view_purchase_request_line_search</field>
        <field name="model">purchase.request.line</field>
        <field name="inherit_id" ref="purchase_request.purchase_request_line_search" />
        <field name="arch" type="xml">
            <field name="requested_by" position="after">
                <field name="department_id" />
            </field>
            <xpath expr="//group[1]" position="inside">
                <filter
                    name="group_department"
                    string="Department"
                    context="{'group_by':'department_id'}"
                />
            </xpath>
        </field>
    </record>
</odoo>
