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

    <!-- ============================================================ -->
    <!--                     Audio File Views                         -->
    <!-- ============================================================ -->

    <record id="view_audio_file_form" model="ir.ui.view">
        <field name="name">encoach.audio.file.form</field>
        <field name="model">encoach.audio.file</field>
        <field name="arch" type="xml">
            <form string="Audio File">
                <sheet>
                    <div class="oe_title">
                        <h1>
                            <field name="topic" placeholder="Audio Topic"/>
                        </h1>
                    </div>
                    <group>
                        <group>
                            <field name="exam_type"/>
                            <field name="part"/>
                            <field name="context_type"/>
                            <field name="difficulty"/>
                        </group>
                        <group>
                            <field name="audio_url" widget="url"/>
                            <field name="ai_generated"/>
                            <field name="approved"/>
                            <field name="ielts_certified"/>
                        </group>
                    </group>
                    <notebook>
                        <page string="Transcript" name="transcript">
                            <field name="transcript" widget="text" placeholder="Audio transcript..."/>
                        </page>
                        <page string="Validation" name="validation">
                            <group>
                                <field name="generation_brief"/>
                                <field name="validation_errors"/>
                            </group>
                        </page>
                    </notebook>
                </sheet>
            </form>
        </field>
    </record>

    <record id="view_audio_file_list" model="ir.ui.view">
        <field name="name">encoach.audio.file.list</field>
        <field name="model">encoach.audio.file</field>
        <field name="arch" type="xml">
            <list string="Audio Files" decoration-success="approved == True">
                <field name="topic"/>
                <field name="exam_type"/>
                <field name="part"/>
                <field name="context_type"/>
                <field name="difficulty"/>
                <field name="approved"/>
            </list>
        </field>
    </record>

    <record id="view_audio_file_search" model="ir.ui.view">
        <field name="name">encoach.audio.file.search</field>
        <field name="model">encoach.audio.file</field>
        <field name="arch" type="xml">
            <search string="Search Audio Files">
                <field name="topic"/>
                <separator/>
                <filter string="Academic" name="filter_academic" domain="[('exam_type', '=', 'academic')]"/>
                <filter string="General Training" name="filter_general" domain="[('exam_type', '=', 'general_training')]"/>
                <filter string="General English" name="filter_general_eng" domain="[('exam_type', '=', 'general_english')]"/>
                <separator/>
                <filter string="Part 1" name="filter_part1" domain="[('part', '=', 1)]"/>
                <filter string="Part 2" name="filter_part2" domain="[('part', '=', 2)]"/>
                <filter string="Part 3" name="filter_part3" domain="[('part', '=', 3)]"/>
                <filter string="Part 4" name="filter_part4" domain="[('part', '=', 4)]"/>
                <separator/>
                <filter string="Approved" name="filter_approved" domain="[('approved', '=', True)]"/>
                <filter string="Exam Type" name="group_exam_type" context="{'group_by': 'exam_type'}"/>
                <filter string="Part" name="group_part" context="{'group_by': 'part'}"/>
                <filter string="Difficulty" name="group_difficulty" context="{'group_by': 'difficulty'}"/>
            </search>
        </field>
    </record>

    <record id="action_audio_file" model="ir.actions.act_window">
        <field name="name">Audio Files</field>
        <field name="res_model">encoach.audio.file</field>
        <field name="view_mode">list,form</field>
        <field name="search_view_id" ref="view_audio_file_search"/>
        <field name="help" type="html">
            <p class="o_view_nocontent_smiling_face">
                Upload your first audio file
            </p>
        </field>
    </record>

</odoo>
