<?xml version="1.0" encoding="UTF-8"?>
<odoo>
        <record id="view_op_assignment_sub_line_tree" model="ir.ui.view">
            <field name="name">op.assignment.sub.line.list</field>
            <field name="model">op.assignment.sub.line</field>
            <field name="priority" eval="8" />
            <field name="arch" type="xml">
                <list string="Assignment Sub Line">
                    <field name="assignment_id" />
                    <field name="student_id" />
                    <field name="submission_date" />
                    <field name="state" />
                    <field name="marks" optional="hide" />
                </list>
            </field>
        </record>

        <record id="view_op_assignment_sub_line_form" model="ir.ui.view">
            <field name="name">op.assignment.sub.line.form</field>
            <field name="model">op.assignment.sub.line</field>
            <field name="priority" eval="8" />
            <field name="arch" type="xml">
                <form string="Assignment Sub Line">
                    <header>
                        <button name="act_submit"
                                invisible="state != 'draft'"
                                type="object"
                                string="Submit"
                                class="oe_highlight" />
                        <button name="act_accept"
                                invisible="state != 'submit'"
                                type="object"
                                string="Accept"
                                groups="openeducat_assignment.group_op_assignment_user"
                                class="oe_highlight" />
                        <button name="act_change_req"
                                invisible="state != 'submit'"
                                type="object"
                                string="Change Require"
                                groups="openeducat_assignment.group_op_assignment_user" />
                        <button name="act_reject"
                                invisible="state != 'submit'"
                                type="object"
                                string="Reject"
                                groups="openeducat_assignment.group_op_assignment_user" />
                        <button name="act_draft"
                                invisible="state != 'change'"
                                type="object"
                                string="Change And Resubmit"
                                groups="openeducat_assignment.group_op_assignment_manager"
                                class="oe_highlight" />
                        <button name="act_draft"
                                invisible="state != 'reject'"
                                type="object"
                                string="Resubmit"
                                groups="openeducat_assignment.group_op_assignment_manager"
                                class="oe_highlight" />
                        <field name="state" widget="statusbar" statusbar_visible="draft,submit,accept" />
                    </header>
                    <sheet>
                        <field name="active" invisible="1" />
                        <widget name="web_ribbon" title="Archived" bg_color="bg-danger" invisible="active == True" />
                        <group>
                            <group>
                                <field name="student_id" readonly="state == 'accept'"/>
                                <field name="assignment_id" domain="[('allocation_ids','=',student_id),('state','=','publish')]"
                                readonly="state == 'accept'" />
                                <field name="marks" readonly="state == 'accept'" />
                            </group>
                            <group>
                                <field name="submission_date" readonly="state == 'accept'" />
                                <field name="user_boolean" invisible="1" />
                            </group>
                        </group>
                        <div>
                            <label for="description" string="Description" class="mt32" readonly="state == 'accept'" />
                            <field name="description" nolabel="1" readonly="state == 'accept'" />
                        </div>
                        <div>
                            <label for="note" string="Note" class="mt32" readonly="state == 'accept'" />
                            <field name="note" nolabel="1" readonly="state == 'accept'" />
                        </div>
                    </sheet>
                    <chatter/>
                </form>
            </field>
        </record>

        <record id="view_op_assignment_sub_line_pivot" model="ir.ui.view">
            <field name="name">op.assignment.sub.line.pivot</field>
            <field name="model">op.assignment.sub.line</field>
            <field name="priority" eval="8" />
            <field name="arch" type="xml">
                <pivot string="Assignment Sub Line">
                    <field name="assignment_id" type="col" />
                    <field name="student_id" />
                    <field name="submission_date" />
                    <field name="state" type="row" />
                </pivot>
            </field>
        </record>

        <record model="ir.ui.view" id="view_op_assignment_sub_line_graph">
            <field name="name">op.assignment.sub.linegraph</field>
            <field name="model">op.assignment.sub.line</field>
            <field name="arch" type="xml">
                <graph string="Assignment Sub Line Graph View" type="pie">
                    <field name="assignment_id" />
                    <field name="state" />
                </graph>
            </field>
        </record>

        <record id="view_op_assignment_sub_line_search" model="ir.ui.view">
            <field name="name">op.assignment.sub.line.search</field>
            <field name="model">op.assignment.sub.line</field>
            <field name="priority" eval="8" />
            <field name="arch" type="xml">
                <search string="Assignment Sub Line">
                    <field name="assignment_id" />
                    <field name="student_id" />
                    <field name="description" />
                    <field name="state" />
                    <field name="submission_date" />
                    <field name="note" />
                    <filter string="Today" name="filter_submission_today" domain="[('submission_date', '&gt;=', time.strftime('%%Y-%%m-%%d 00:00:00')),('submission_date', '&lt;=', time.strftime('%%Y-%%m-%%d 23:59:59'))]" />
                    <filter string="Week" name="filter_submission_week" domain="[('submission_date', '&gt;=',(context_today()+relativedelta(weeks=-1,days=1,weekday=0)).strftime('%Y-%m-%d 00:00:00')),
                                    ('submission_date', '&lt;', (context_today()+relativedelta(weekday=6)).strftime('%Y-%m-%d 23:59:59'))]" />
                    <filter string="Month" name="filter_submission_month" domain="[('submission_date', '&lt;=', (datetime.date.today()+relativedelta(day=31)).strftime('%Y-%m-%d')),
                                    ('submission_date', '&gt;=', (datetime.date.today()-relativedelta(day=1)).strftime('%Y-%m-%d'))]" />
                    <filter string="Archived" name="inactive" domain="[('active', '=', False)]" />

                    <group>
                        <filter string="Assignment" domain="[]" name="group_by_assignment_id" context="{'group_by':'assignment_id'}" />
                        <filter string="Student" domain="[]" name="group_by_assignment_student_id" context="{'group_by':'student_id'}" />
                        <filter string="State" domain="[]" name="group_by_assignment_state" context="{'group_by':'state'}" />
                        <filter string="Submission Date" domain="[]" name="group_by_assignment_submission" context="{'group_by':'submission_date'}" />
                        <filter string="Marks" domain="[]" name="group_by_assignment_marks" context="{'group_by':'marks'}" />
                    </group>
                </search>
            </field>
        </record>

        <record model="ir.actions.act_window" id="act_open_op_assignment_sub_line_view">
            <field name="name">Assignment Submissions</field>
            <field name="path">assignment-sub-line</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">op.assignment.sub.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_assignment_sub_line_search" />
        </record>

        <record model="ir.actions.act_window.view" id="act_open_op_assignment_sub_line_view_form">
            <field name="act_window_id" ref="act_open_op_assignment_sub_line_view" />
            <field name="sequence" eval="20" />
            <field name="view_mode">form</field>
            <field name="view_id" ref="view_op_assignment_sub_line_form" />
        </record>

        <record model="ir.actions.act_window.view" id="act_open_op_assignment_sub_line_view_tree">
            <field name="act_window_id" ref="act_open_op_assignment_sub_line_view" />
            <field name="sequence" eval="10" />
            <field name="view_mode">list</field>
            <field name="view_id" ref="view_op_assignment_sub_line_tree" />
        </record>

        <record model="ir.actions.act_window" id="act_open_op_assignment_sub_line_view_pivot">
            <field name="name">Assignment Submission Analysis Pivot</field>
            <field name="res_model">op.assignment.sub.line</field>
            <field name="view_mode">pivot</field>
            <field name="view_id" ref="view_op_assignment_sub_line_pivot" />
        </record>

</odoo>
