<?xml version="1.0" encoding="utf-8" ?>
<odoo>
    <record id="hr_equipment_view_form" model="ir.ui.view">
        <field name="name">equipment.form@maintenance_plan</field>
        <field name="inherit_id" ref="maintenance.hr_equipment_view_form" />
        <field name="model">maintenance.equipment</field>
        <field name="arch" type="xml">
            <div name="button_box" position="inside">
                <button
                    name="%(maintenance_plan_equipment_action)d"
                    type="action"
                    class="oe_stat_button"
                    icon="fa-list"
                >
                    <field
                        string="Plans"
                        name="search_maintenance_plan_count"
                        widget="statinfo"
                    />
                </button>
            </div>
            <xpath expr="//group[@name='statistics']" position="attributes">
                <attribute name="invisible">True</attribute>
            </xpath>
            <xpath expr="//group[@name='statistics']/.." position="before">
                <field
                    name="maintenance_plan_ids"
                    nolabel="1"
                    context="{'default_equipment_id': id, 'hide_equipment_id': 1}"
                >
                    <list>
                        <field name="maintenance_kind_id" string="Kind" />
                        <field name="maintenance_team_id" string="Team" />
                        <field name="name" />
                        <field name="start_maintenance_date" string="Start Date" />
                        <field name="interval" />
                        <field name="interval_step" />
                        <field name="duration" />
                        <field name="next_maintenance_date" />
                        <field
                            name="maintenance_plan_horizon"
                            string="P. Horizon period"
                        />
                        <field name="planning_step" string="P. Horizon step" />
                    </list>
                </field>
            </xpath>
            <field name="maintenance_team_id" position="attributes">
                <attribute name="required">maintenance_team_required</attribute>
            </field>
        </field>
    </record>

    <record id="hr_equipment_view_search" model="ir.ui.view">
        <field name="name">equipment.search@maintenance_plan</field>
        <field name="model">maintenance.equipment</field>
        <field name="inherit_id" ref="maintenance.hr_equipment_view_search" />
        <field name="arch" type="xml">
            <xpath expr="//field[@name='owner_user_id']" position="after">
                <field name="maintenance_team_id" />
            </xpath>
        </field>
    </record>

    <record id="maintenance.hr_equipment_action" model="ir.actions.act_window">
        <field name="context">{'hide_equipment_id': 1}</field>
    </record>
</odoo>
