<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <record model="res.groups.privilege" id="privilege_module_category_all_op_assignment">
        <field name="name">Assignment</field>
        <field name="description">Helps you manage your institutes different-different users.</field>
        <field name="sequence">105</field>
    </record>

    <record model="res.groups.privilege" id="privilege_module_category_openeducat_assignment">
        <field name="name">Assignment</field>
        <field name="description">Helps you manage your institutes different-different users.</field>
        <field name="category_id" ref="privilege_module_category_all_op_assignment"/>
        <field name="sequence">16</field>
    </record>

    <record id="group_op_assignment_user" model="res.groups">
        <field name="name">User</field>
        <field name="privilege_id" ref="privilege_module_category_openeducat_assignment"/>
        <field name="user_ids" eval="[(4, ref('base.user_admin'))]"/>
        <field name="implied_ids"
               eval="[(4, ref('base.group_user'))]"/>
    </record>

    <record id="group_op_assignment_manager" model="res.groups">
        <field name="name">Manager</field>
        <field name="privilege_id" ref="privilege_module_category_openeducat_assignment"/>
        <field name="user_ids" eval="[(4, ref('base.user_admin'))]"/>
        <field name="implied_ids"
               eval="[(4, ref('openeducat_assignment.group_op_assignment_user'))]"/>
    </record>


    <record model="ir.rule" id="student_assignment_sub_line_rule">
        <field name="name">Student Assignment Submission Line Rule</field>
        <field name="model_id" ref="model_op_assignment_sub_line"/>
        <field name="groups"
               eval="[(4, ref('openeducat_assignment.group_op_assignment_manager'))]"/>
        <field name="domain_force">['|', ('student_id.user_id','=',user.id), ('student_id.user_id','in',
            user.child_ids.ids)]
        </field>
    </record>

    <record model="ir.rule" id="user_assignment_rule">
        <field name="name">User Assignment rule</field>
        <field name="model_id" ref="model_op_assignment"/>
        <field name="groups"
               eval="[(4, ref('openeducat_assignment.group_op_assignment_user'))]"/>
        <field name="domain_force">[('faculty_id.user_id','=',user.id)]</field>
    </record>

    <record model="ir.rule" id="user_assignment_sub_line_rule">
        <field name="name">User Assignment Submission Line Rule</field>
        <field name="model_id" ref="model_op_assignment_sub_line"/>
        <field name="groups"
               eval="[(4, ref('openeducat_assignment.group_op_assignment_user'))]"/>
        <field name="domain_force">[('assignment_id.faculty_id.user_id','=',user.id)]</field>
    </record>

    <record model="ir.rule" id="manager_assignment_rule">
        <field name="name">Manager Assignment rule</field>
        <field name="model_id" ref="model_op_assignment"/>
        <field name="groups"
               eval="[(4, ref('openeducat_assignment.group_op_assignment_manager'))]"/>
        <field name="domain_force">[(1,'=',1)]</field>
    </record>

    <record model="ir.rule" id="manager_assignment_sub_line_rule">
        <field name="name">Manager Assignment Submission Line Rule</field>
        <field name="model_id" ref="model_op_assignment_sub_line"/>
        <field name="groups"
               eval="[(4, ref('openeducat_assignment.group_op_assignment_manager'))]"/>
        <field name="domain_force">[(1,'=',1)]</field>
    </record>
</odoo>
