<?xml version="1.0" encoding="utf-8" ?>
<odoo>
    <record id="hr_equipment_request_view_search" model="ir.ui.view">
        <field name="model">maintenance.request</field>
        <field name="inherit_id" ref="maintenance.hr_equipment_request_view_search" />
        <field name="arch" type="xml">
            <xpath expr="//field[@name='maintenance_team_id']" position="after">
                <field name="project_id" groups="project.group_project_user" />
            </xpath>
        </field>
    </record>
    <record id="hr_equipment_request_view_tree" model="ir.ui.view">
        <field name="model">maintenance.request</field>
        <field name="inherit_id" ref="maintenance.hr_equipment_request_view_tree" />
        <field name="arch" type="xml">
            <xpath expr="//field[@name='category_id']" position="after">
                <field name="project_id" groups="project.group_project_user" />
            </xpath>
        </field>
    </record>
    <record id="hr_equipment_request_view_kanban" model="ir.ui.view">
        <field name="model">maintenance.request</field>
        <field name="inherit_id" ref="maintenance.hr_equipment_request_view_kanban" />
        <field name="arch" type="xml">
            <xpath expr="//field[@name='archive']" position="before">
                <field name="project_id" groups="project.group_project_user" />
            </xpath>
            <xpath
                expr="//t[@t-name='card']//field[@name='schedule_date']"
                position="after"
            >
                <div
                    t-if="record.project_id.raw_value"
                    groups="project.group_project_user"
                >
                    <small>Project: <t t-out="record.project_id.value" /></small>
                </div>
            </xpath>
        </field>
    </record>
    <record id="hr_equipment_request_view_form" model="ir.ui.view">
        <field name="model">maintenance.request</field>
        <field name="inherit_id" ref="maintenance.hr_equipment_request_view_form" />
        <field name="arch" type="xml">
            <xpath expr="//field[@name='priority']" position="after">
                <field name="project_id" invisible="1" />
                <field name="project_id" groups="project.group_project_user" />
                <field name="task_id" invisible="1" />
                <field
                    name="task_id"
                    domain="[('project_id', '=', project_id)]"
                    context="{'default_project_id': project_id}"
                    groups="project.group_project_user"
                />
                <field name="milestone_id" invisible="1" />
                <t groups="project.group_project_milestone">
                    <field
                        name="milestone_id"
                        domain="[('project_id', '=', project_id)]"
                        groups="project.group_project_user"
                        context="{'default_project_id': project_id}"
                    />
                </t>
            </xpath>
        </field>
    </record>

    <record
        id="action_view_maintenance_request_for_milestone"
        model="ir.actions.act_window"
    >
        <field name="name">Maintenance Requests</field>
        <field name="res_model">maintenance.request</field>
        <field name="view_mode">kanban,list,calendar,pivot,graph,activity,form</field>
        <field name="context">{'default_milestone_id': active_id}</field>
        <field name="domain">[('milestone_id', '=', active_id)]</field>
        <field name="help" type="html">
            <p class="o_view_nocontent_smiling_face">
                No maintenance requests found. Let's create one!
            </p>
        </field>
    </record>
</odoo>
