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

        <record id="view_op_result_template_tree" model="ir.ui.view">
            <field name="name">op.result.template.list</field>
            <field name="model">op.result.template</field>
            <field name="priority" eval="8"/>
            <field name="arch" type="xml">
                <list string="Result Template">
                    <field name="name"/>
                    <field name="exam_session_id"/>
                    <field name="result_date"/>
                </list>
            </field>
        </record>

        <record id="view_op_result_template_form" model="ir.ui.view">
            <field name="name">op.result.template.form</field>
            <field name="model">op.result.template</field>
            <field name="priority" eval="8"/>
            <field name="arch" type="xml">
                <form string="Result Template">
                    <header groups="openeducat_exam.group_op_exam_admin">
                        <button string="Generate Result" type="object" invisible="state != 'draft'" name="generate_result"
                                class="oe_highlight"/>
                        <field name="state" widget="statusbar" statusbar_visible="draft,result_generated"/>
                    </header>
                    <sheet>
                        <field name="active" invisible="1"/>
                        <widget name="web_ribbon" title="Archived" bg_color="bg-danger"
                                invisible="active == True"/>
                        <group>
                            <group>
                                <field name="name" select="1"/>
                                <field name="exam_session_id"/>
                            </group>
                            <group>
                                <field name="result_date"/>
                                <field name="evaluation_type"/>
                            </group>
                        </group>
                        <separator string="Grades" colspan="4"
                                   invisible="evaluation_type != 'grade'"/>
                        <field name="grade_ids" colspan="4" nolabel="1"
                               invisible="evaluation_type != 'grade'" required="evaluation_type != 'grade'"/>
                    </sheet>
                   <chatter/>
                </form>
            </field>
        </record>

        <record id="view_op_result_template_search" model="ir.ui.view">
            <field name="name">op.result.template.search</field>
            <field name="model">op.result.template</field>
            <field name="priority" eval="8"/>
            <field name="arch" type="xml">
                <search string="Result Template">
                    <field name="name" select="True"/>
                    <field name="exam_session_id"/>
                    <field name="result_date" select="True"/>
                    <filter string="Archived" name="inactive"
                            domain="[('active', '=', False)]"/>
                </search>
            </field>
        </record>

        <record model="ir.actions.act_window" id="act_open_op_result_template_view">
            <field name="name">Result Templates</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">op.result.template</field>
            <field name="path">result-template</field>
            <field name="binding_view_types">form</field>
            <field name="view_mode">list,form</field>
            <field name="search_view_id" ref="view_op_result_template_search"/>
            <field name="domain">[]</field>
            <field name="context">{}</field>
        </record>

        <record model="ir.actions.act_window.view" id="act_open_op_result_template_view_form">
            <field name="act_window_id" ref="act_open_op_result_template_view"/>
            <field name="sequence" eval="20"/>
            <field name="view_mode">form</field>
            <field name="view_id" ref="view_op_result_template_form"/>
        </record>

        <record model="ir.actions.act_window.view" id="act_open_op_result_template_view_tree">
            <field name="act_window_id" ref="act_open_op_result_template_view"/>
            <field name="sequence" eval="10"/>
            <field name="view_mode">list</field>
            <field name="view_id" ref="view_op_result_template_tree"/>
        </record>

</odoo>
