<?xml version="1.0" encoding="utf-8"?>
<odoo>

    <record id="view_course_module_form" model="ir.ui.view">
        <field name="name">encoach.course.module.form</field>
        <field name="model">encoach.course.module</field>
        <field name="arch" type="xml">
            <form string="Course Module">
                <header>
                    <field name="status" widget="statusbar" statusbar_visible="locked,available,in_progress,completed"/>
                </header>
                <sheet>
                    <group>
                        <group>
                            <field name="name"/>
                            <field name="course_id"/>
                            <field name="cefr_target"/>
                            <field name="auto_generated"/>
                        </group>
                        <group>
                            <field name="completion_criteria"/>
                            <field name="score_threshold" invisible="completion_criteria != 'score_threshold'"/>
                            <field name="prerequisite_module_id"/>
                            <field name="sequence"/>
                        </group>
                    </group>
                    <group>
                        <field name="generation_brief"/>
                    </group>
                </sheet>
            </form>
        </field>
    </record>

    <record id="view_course_module_list" model="ir.ui.view">
        <field name="name">encoach.course.module.list</field>
        <field name="model">encoach.course.module</field>
        <field name="arch" type="xml">
            <list string="Course Modules">
                <field name="sequence" widget="handle"/>
                <field name="name"/>
                <field name="course_id"/>
                <field name="cefr_target"/>
                <field name="status" widget="badge" decoration-info="status == 'available'" decoration-success="status == 'completed'" decoration-warning="status == 'in_progress'"/>
            </list>
        </field>
    </record>

    <record id="view_course_module_search" model="ir.ui.view">
        <field name="name">encoach.course.module.search</field>
        <field name="model">encoach.course.module</field>
        <field name="arch" type="xml">
            <search string="Search Course Modules">
                <field name="name"/>
                <field name="course_id"/>
                <separator/>
                <filter string="Locked" name="locked" domain="[('status', '=', 'locked')]"/>
                <filter string="Available" name="available" domain="[('status', '=', 'available')]"/>
                <filter string="In Progress" name="in_progress" domain="[('status', '=', 'in_progress')]"/>
                <filter string="Completed" name="completed" domain="[('status', '=', 'completed')]"/>
                <filter string="Skipped" name="skipped" domain="[('status', '=', 'skipped')]"/>
                <separator/>
                <filter string="Course" name="group_course" context="{'group_by': 'course_id'}"/>
            </search>
        </field>
    </record>

    <record id="action_course_module" model="ir.actions.act_window">
        <field name="name">Course Modules</field>
        <field name="res_model">encoach.course.module</field>
        <field name="view_mode">list,form</field>
    </record>

</odoo>
