<?xml version="1.0" encoding="UTF-8"?>
<odoo>
    <!-- Tree View -->
    <record id="view_education_status_tree" model="ir.ui.view">
        <field name="name">education.status.tree</field>
        <field name="model">education.status</field>
        <field name="arch" type="xml">
            <tree>
                <field name="name"/>
                <field
                        name="education_status_type"
                        decoration-success="education_status_type == 'current'"
                        decoration-danger="education_status_type == 'previous'"
                        widget="badge"
                        invisible="1"
                />
                <!-- <field name="education_status" optional="hide"/> -->
                <field name="case_study" optional="show"/>
                <field name="intermittent_reason_id"
                       attrs="{'invisible': [('case_study', '!=', 'intermittent')], 'required': [('case_study', '=', 'intermittent')]}"
                       optional="hide" options="{'no_create_edit': True, 'no_create': True}"/>
                <field name="intermittent_date"
                       attrs="{'invisible': [('case_study', '!=', 'intermittent')], 'required': [('case_study', '=', 'intermittent')]}"
                       optional="hide"/>
                <field name="education_levels" optional="show" options="{'no_create_edit': True, 'no_create': True}"/>
                <field name="entities" optional="show" options="{'no_create_edit': True, 'no_create': True}"/>
                <field name="classroom" optional="show" options="{'no_create_edit': True, 'no_create': True}"/>
                <field name="rate_type"/>
                <field name="percentage"/>
                <field name="degree"/>
                <field name="education_entity" optional="hide"/>
                <field name="education_period_id" optional="show"/>
                <field name="education_start_date" optional="show"/>
                <field name="education_end_date" optional="show"/>
                <field name="family_member_age" optional="show"/>
                <field name="family_member_delay" attrs="{'invisible': [('family_member_delay', '=', False)]}"/>
                <field name="delay_reason_id" options="{'no_create_edit': True, 'no_create': True}"
                       attrs="{'invisible': [('family_member_delay', '=', False)], 'required': [('family_member_delay', '=', True)]}"/>
                <field name="educational_certificate" optional="hide"/>
                <field name="specialization_ids" optional="hide"/>
                <!-- <field name="weak_study" optional="hide"/> -->
            </tree>
        </field>
    </record>

    <!-- Form View -->
    <record id="view_education_status_form" model="ir.ui.view">
        <field name="name">education.status.form</field>
        <field name="model">education.status</field>
        <field name="arch" type="xml">
            <form>
                <sheet>
                    <!-- Title -->
                    <div class="oe_title">
                        <h1>
                            <field name="name"/>
                        </h1>
                    </div>

                    <!-- Basic Info -->
                    <group>
                        <field name="education_status_type" required="0" invisible="1"/>
                    </group>

                    <!-- Conditional Fields (Current) -->
                    <group>
                        <group>
                            <!-- <field name="education_status"/> -->
                            <field name="case_study" required="1"/>
                            <field name="intermittent_reason_id"
                                   attrs="{'invisible': [('case_study', '!=', 'intermittent')], 'required': [('case_study', '=', 'intermittent')]}"
                                   options="{'no_create_edit': True, 'no_create': True}"/>
                            <field name="intermittent_date"
                                   attrs="{'invisible': [('case_study', '!=', 'intermittent')], 'required': [('case_study', '=', 'intermittent')]}"/>
                            <field name="education_levels" required="1"
                                   options="{'no_create_edit': True, 'no_create': True}"/>
                            <field name="entities" required="1" options="{'no_create_edit': True, 'no_create': True}"/>
                            <field name="education_period_id" required="1"
                                   options="{'no_create_edit': True, 'no_create': True}"/>
                            <field name="classroom" required="1" options="{'no_create_edit': True, 'no_create': True}"/>
                        </group>
                        <group>
                            <field name="education_start_date" required="1" force_save="1"/>
                            <field name="education_end_date" required="1" force_save="1"/>
                            <field name="family_member_age"/>
                            <field name="family_member_delay"
                                   attrs="{'invisible': [('family_member_delay', '=', False)]}"/>
                            <field name="delay_reason_id"
                                   attrs="{'invisible': [('family_member_delay', '=', False)], 'required': [('family_member_delay', '=', True)]}"/>
                        </group>
                    </group>


                    <!-- Conditional Fields (Previous) -->
                    <!-- <group attrs="{'invisible': [('education_status_type', '!=', 'previous')]}">
                        <field name="weak_study" widget="many2many_tags"/>
                    </group> -->

                    <!-- Other Fields -->
                    <group>
                        <group>
                            <field name="rate_type" required="1"/>
                            <field name="percentage" required="1"/>
                            <field name="degree" readonly="1" force_save="1"/>
                        </group>
                        <group>
                            <field name="education_entity" required="1"/>
                            <field name="educational_certificate" widget="many2many_attachment_preview"/>
                            <field name="specialization_ids" required="1"/>
                        </group>
                    </group>
                    <notebook>
                        <page string="Weak Classes">
                            <field name="weak_course_ids">
                                <tree editable="bottom">
                                    <field name="weak_course_id"/>
                                    <field name="result_before"/>
                                    <field name="remedial_class_name"/>
                                    <field name="result_after"/>
                                </tree>
                            </field>
                        </page>
                    </notebook>
                </sheet>
            </form>
        </field>
    </record>
</odoo>
