<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
    <record id="view_hr_employee_form" model="ir.ui.view">
        <field name="name">hr.employee.course.form</field>
        <field name="model">hr.employee</field>
        <field name="inherit_id" ref="hr.view_employee_form" />
        <field name="arch" type="xml">
            <div name="button_box" position="inside">
                <button
                    name="action_view_course"
                    type="object"
                    icon="fa-graduation-cap"
                    class="oe_stat_button"
                >
                    <field name="count_courses" widget="statinfo" string="Courses" />
                    <field name='courses_ids' invisible="1" />
                </button>
            </div>
        </field>
    </record>
    <record model="ir.ui.view" id="hr_course_attendee_tree_employee_view">
        <field name="name">hr.course.attendee.tree.employee</field>
        <field name="model">hr.course.attendee</field>
        <field name="priority">100</field>
        <field name="arch" type="xml">
            <tree
                create="false"
                delete="false"
                decoration-muted="state=='cancelled'"
                decoration-success="state!='cancelled' and result=='passed'"
                decoration-danger="state!='cancelled' and (result=='failed' or result=='absent')"
            >
                <field name="course_schedule_id" />
                <field name="state" />
                <field name="course_start" />
                <field name="course_end" />
                <field name="result" />
            </tree>
        </field>
    </record>
    <record id="action_view_course" model="ir.actions.act_window">
        <field name="name">Courses</field>
        <field name="res_model">hr.course.attendee</field>
        <field name="view_mode">tree,form</field>
        <field
            name="view_ids"
            eval="[(5,0,0),
                          (0,0,{'view_mode':'tree', 'view_id': ref('hr_course_attendee_tree_employee_view')}),
                          (0,0,{'view_mode':'form'})]"
        />
    </record>
</odoo>
