<?xml version="1.0" encoding="UTF-8"?>
<odoo>
        <record id="view_op_attendance_line_tree" model="ir.ui.view">
            <field name="name">op.attendance.line.list</field>
            <field name="model">op.attendance.line</field>
            <field name="priority" eval="8"/>
            <field name="arch" type="xml">
                <list string="Attendance Line">
                    <field name="attendance_id" optional="show"/>
                    <field name="attendance_date"/>
                    <field name="student_id"/>
                    <field name="course_id" optional="show"/>
                    <field name="batch_id" optional="show"/>
                    <field name="present"/>
                    <field name="absent"/>
                    <field name="excused"/>
                    <field name="late"/>
                    <field name="attendance_type_id" optional="hide"/>
                    <field name="remark" optional="hide"/>
                </list>
            </field>
        </record>

        <record id="view_op_attendance_line_form" model="ir.ui.view">
            <field name="name">op.attendance.line.form</field>
            <field name="model">op.attendance.line</field>
            <field name="priority" eval="8"/>
            <field name="arch" type="xml">
                <form string="Attendance Line">
                    <header/>
                    <sheet>
                        <field name="active" invisible="1"/>
                        <widget name="web_ribbon" title="Archived" bg_color="bg-danger"
                                invisible="active == True"/>
                        <group>
                            <group>
                                <field name="attendance_id" widget="selection"/>
                                <field name="present" readonly="state == 'done'" />
                                <field name="excused" readonly="state == 'done'"/>
                                <field name="remark"/>
                                <field name="batch_id" widget="selection"/>
                                <field name="attendance_date"/>
                            </group>
                            <group>
                                <field name="student_id"
                                       domain="[('course_detail_ids.course_id','=',course_id),('course_detail_ids.batch_id','=',batch_id)]"/>
                                <field name="attendance_type_id" options='{"no_open": True}'/>
                                <field name="absent" readonly="state == 'done'" />
                                <field name="late" readonly="state == 'done'" />
                                <field name="course_id" widget="selection"/>
                                <field name="state" />
                            </group>
                        </group>
                    </sheet>
                    <chatter/>
                </form>
            </field>
        </record>

        <record id="view_op_attendance_line_search" model="ir.ui.view">
            <field name="name">op.attendance.line.search</field>
            <field name="model">op.attendance.line</field>
            <field name="priority" eval="8"/>
            <field name="arch" type="xml">
                <search string="Attendance Line">
                    <field name="attendance_id"/>
                    <field name="student_id"/>
                    <field name="present"/>
                    <filter string="Present" name="group_by_attendance_present"
                            domain="[('present', '=', True)]"/>
                    <filter string="Absent" name="group_by_attendance_absent"
                            domain="[('present', '=', False)]"/>
                    <filter string="Today" name="group_by_attendance_today"
                            domain="[('attendance_date', '=', context_today().strftime('%Y-%m-%d'))]"/>
                    <filter string="Archived" name="inactive"
                            domain="[('active', '=', False)]"/>
                    <group>
                        <filter string="Attendance" name="group_by_attendance"
                                domain="[]" context="{'group_by':'attendance_id'}"/>
                        <filter string="Course" name="group_by_attendance_course"
                                domain="[]" context="{'group_by':'course_id'}"/>
                        <filter string="Batch" name="group_by_attendance_batch"
                                domain="[]" context="{'group_by':'batch_id'}"/>
                        <filter string="Student" name="group_by_attendance_student"
                                domain="[]" context="{'group_by':'student_id'}"/>
                        <filter string="Present ?" name="group_by_attendance_present"
                                domain="[]" context="{'group_by':'present'}"/>
                        <filter string="Date" name="group_by_attendance_date"
                                domain="[]" context="{'group_by':'attendance_date'}"/>
                    </group>
                </search>
            </field>
        </record>

        <record id="view_op_attendance_line_pivot" model="ir.ui.view">
            <field name="name">op.attendance.line.pivot</field>
            <field name="model">op.attendance.line</field>
            <field name="priority" eval="8"/>
            <field name="arch" type="xml">
                <pivot string="Attendance Analysis">
                    <field name="attendance_id" type="row"/>
                    <field name="student_id"/>
                    <field name="present"/>
                    <field name="remark"/>
                    <field name="course_id"/>
                    <field name="batch_id"/>
                    <field name="attendance_date"/>
                    <field name="register_id" type="col"/>
                </pivot>
            </field>
        </record>

        <record model="ir.ui.view" id="view_op_attendance_line_graph">
            <field name="name">op.attendance.line.graph</field>
            <field name="model">op.attendance.line</field>
            <field name="arch" type="xml">
                <graph string="Attendance Line" type="bar">
                    <field name="student_id"/>
                    <field name="remark"/>
                </graph>
            </field>
        </record>


        <record model="ir.actions.act_window" id="act_open_op_attendance_line_view">
            <field name="name">Attendance Line</field>
            <field name="path">attendance-line</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">op.attendance.line</field>
            <field name="binding_view_types">form</field>
            <field name="view_mode">list,form,pivot,graph</field>
            <field name="search_view_id" ref="view_op_attendance_line_search"/>
            <field name="domain">[]</field>
            <field name="context">{}</field>
        </record>

        <record model="ir.actions.act_window.view" id="act_open_op_attendance_line_view_form">
            <field name="act_window_id" ref="act_open_op_attendance_line_view"/>
            <field name="sequence" eval="20"/>
            <field name="view_mode">form</field>
            <field name="view_id" ref="view_op_attendance_line_form"/>
        </record>

        <record model="ir.actions.act_window.view" id="act_open_op_attendance_line_view_tree">
            <field name="act_window_id" ref="act_open_op_attendance_line_view"/>
            <field name="sequence" eval="10"/>
            <field name="view_mode">list</field>
            <field name="view_id" ref="view_op_attendance_line_tree"/>
        </record>

</odoo>
