<odoo>
    <data noupdate="0">
        <record model="ir.module.category" id="module_category_benefit">
            <field name="name">Beneficiaries Management</field>
            <field name="description">Helps you manage Beneficiaries Program</field>
            <field name="sequence">1</field>
        </record>

<!--       record <record id="translation_benefit_ar" model="ir.translation">-->
<!--            <field name="name">ir.module.category,name</field>-->
<!--            <field name="lang">ar_001</field>-->
<!--            <field name="type">model</field>-->
<!--            <field name="res_id" eval="ref('module_category_benefit')"/>-->
<!--            <field name="src">Beneficiaries Management</field>-->
<!--            <field name="value">فئات المستفيدين</field>-->
<!--        </record>-->

        <!--        <record id="group_benefit_user" model="res.groups">-->
        <!--            <field name="name">Beneficiaries User</field>-->
        <!--            <field name="category_id" ref="module_category_benefit"/>-->
        <!--            <field name="users" eval="[(4, ref('base.user_root'))]"/>-->
        <!--&lt;!&ndash;            <field name="implied_ids" eval="[(4, ref('base.group_erp_manager'))]"/>&ndash;&gt;-->
        <!--        </record>-->
        <record id="group_benefit_info" model="res.groups">
            <field name="name">Beneficiaries Inforamtion</field>
            <field name="category_id" ref="module_category_benefit"/>
            <field name="users" eval="[(4, ref('base.user_root'))]"/>
            <field name="comment">the user will be able to approve Beneficiaries requests.</field>
        </record>

        <record id="group_benefit_back_to_draft" model="res.groups">
            <field name="name">Return Benefit Profile to Draft</field>
            <field name="category_id" ref="module_category_benefit"/>
            <field name="users" eval="[(4, ref('base.user_root'))]"/>
            <field name="comment">Allows the user to return a benefit profile to draft status.</field>
        </record>

        <record id="group_benefit_show_draft_record" model="res.groups">
            <field name="name">Show Draft Records</field>
            <field name="category_id" ref="module_category_benefit"/>
            <field name="users" eval="[(4, ref('base.user_root'))]"/>
        </record>
        <!--         <record id="group_benefit_officer" model="res.groups">-->
        <!--            <field name="name">Beneficiaries Officer</field>-->
        <!--            <field name="category_id" ref="module_category_benefit"/>-->
        <!--            <field name="users" eval="[(4, ref('base.user_root'))]"/>-->
        <!--            <field name="implied_ids" eval="[(4, ref('group_benefit_user')),(4, ref('group_benefit_edit'))]"/>-->
        <!--        </record>-->
        <record id="group_benefit_manager" model="res.groups">
            <field name="name">Beneficiaries Manager</field>
            <field name="category_id" ref="module_category_benefit"/>
            <field name="users" eval="[(4, ref('base.user_root'))]"/>
            <field name="implied_ids" eval="[(4, ref('group_benefit_info'))]"/>
            <field name="comment">the user will be able to approve Beneficiaries requests.</field>
        </record>
        <record id="group_benefit_researcher" model="res.groups">
            <field name="name">Beneficiaries Researcher</field>
            <field name="category_id" ref="module_category_benefit"/>
            <field name="users" eval="[(4, ref('base.user_root'))]"/>
            <field name="implied_ids" eval="[(4, ref('group_benefit_info'))]"/>
        </record>

        <record id="group_benefit_supervisor" model="res.groups">
            <field name="name">Researcher Supervisor</field>
            <field name="category_id" ref="module_category_benefit"/>
            <field name="users" eval="[(4, ref('base.user_root'))]"/>
            <field name="implied_ids" eval="[(4, ref('group_benefit_researcher'))]"/>
        </record>

        <record id="group_family_member_exception" model="res.groups">
            <field name="name">Family Member Exception</field>
            <field name="category_id" ref="module_category_benefit"/>
            <field name="users" eval="[(4, ref('base.user_root'))]"/>
        </record>

        <record id="group_benefit_woman_commitee" model="res.groups">
            <field name="name">Head of the Women's Committee</field>
            <field name="category_id" ref="module_category_benefit"/>
            <field name="users" eval="[(4, ref('base.user_root'))]"/>
            <field name="implied_ids" eval="[(4, ref('group_benefit_info'))]"/>
        </record>

        <record id="group_benefit_branch_manager" model="res.groups">
            <field name="name">Branch Manager</field>
            <field name="category_id" ref="module_category_benefit"/>
            <field name="users" eval="[(4, ref('base.user_root'))]"/>
            <field name="implied_ids" eval="[(4, ref('group_benefit_info'))]"/>
        </record>
        <record id="group_benefit_accountant_accept" model="res.groups">
            <field name="name">Service Request Accountant Accept</field>
            <field name="category_id" ref="odex25_account_payment_fix.module_category_payment_access"/>
            <!--            <field name="implied_ids" eval="[(4, ref('group_benefit_info'))]"/>-->
        </record>
        <record id="group_benefit_payment_accountant_accept" model="res.groups">
            <field name="name">Payment Orders Accountant Accept</field>
            <field name="category_id" ref="odex25_account_payment_fix.module_category_payment_access"/>
            <!--            <field name="implied_ids" eval="[(4, ref('group_benefit_info'))]"/>-->
        </record>

        <record id="group_otp_manager" model="res.groups">
            <field name="name">OTP Manager</field>
            <field name="category_id" ref="module_category_benefit"/>
            <field name="users" eval="[(4, ref('base.user_root'))]"/>
        </record>

        <record id="group_family_service_receipt" model="res.groups">
            <field name="name">Family Service Receipt</field>
            <field name="category_id" ref="module_category_benefit"/>
            <field name="users" eval="[(4, ref('base.user_root'))]"/>
        </record>

        <record id="group_family_services_manager" model="res.groups">
            <field name="name">Family Services Manager</field>
            <field name="category_id" ref="module_category_benefit"/>
            <field name="users" eval="[(4, ref('base.user_root'))]"/>
        </record>

        <record id="group_service_legal_department" model="res.groups">
            <field name="name">Services - Legal Department</field>
            <field name="category_id" ref="module_category_benefit"/>
            <field name="users" eval="[(4, ref('base.user_root'))]"/>
        </record>

        <record id="group_service_projects_department" model="res.groups">
            <field name="name">Services - Projects Department</field>
            <field name="category_id" ref="module_category_benefit"/>
            <field name="users" eval="[(4, ref('base.user_root'))]"/>
        </record>

        <record id="group_benefit_settings" model="res.groups">
            <field name="name">Benefit Settings</field>
            <field name="category_id" ref="module_category_benefit"/>
            <field name="users" eval="[(4, ref('base.user_root'))]"/>
        </record>

        <!-- Add rules for grant.benefit -->
        <record id="grant_benefit_show_all_rule" model="ir.rule">
            <field name="name">Show All Benefits Profiles</field>
            <field name="model_id" ref="model_grant_benefit"/>
            <field name="domain_force">[(1, '=', 1)]</field>
            <field name="groups" eval="[(4, ref('group_benefit_manager')),(4, ref('group_benefit_supervisor')),(4, ref('group_family_services_manager'))]"/>
            <field name="active" eval="True" />
        </record>

        <record id="grant_benefit_rule_branch_manager" model="ir.rule">
            <field name="name">Show Benefits Profiles of Own Branch</field>
            <field name="model_id" ref="model_grant_benefit"/>
            <field name="domain_force">[('branch_custom_id.branch.manager_id', '=', user.employee_id.id)]</field>
            <field name="groups" eval="[(4, ref('group_benefit_branch_manager'))]"/>
            <field name="active" eval="True" />
        </record>

        <record id="grant_benefit_rule_operation_manager" model="ir.rule">
            <field name="name">Show Benefits Profiles of Assigned Branch (Operation Manager)</field>
            <field name="model_id" ref="model_grant_benefit"/>
            <field name="domain_force">[('branch_custom_id.branch.operation_manager_id', '=', user.employee_id.id)]</field>
            <field name="groups" eval="[(4, ref('group_benefit_woman_commitee'))]"/>
            <field name="active" eval="True" />
        </record>

        <record id="grant_benefit_rule_researcher" model="ir.rule">
            <field name="name">Show Benefits Profiles Created or Assigned (Researcher)</field>
            <field name="model_id" ref="model_grant_benefit"/>
            <field name="domain_force">['|','|',('create_uid','=',user.id),('assigned_researcher_id.employee_id','in', user.employee_id.ids),('researcher_id.employee_id', 'in', user.employee_id.ids)]</field>
            <field name="groups" eval="[(4, ref('group_benefit_researcher'))]"/>
            <field name="active" eval="True" />
        </record>

        <!-- Add rules for visit.location -->
        <record id="visit_location_show_all_rule" model="ir.rule">
            <field name="name">Show All Visit Location</field>
            <field name="model_id" ref="model_visit_location"/>
            <field name="domain_force">[(1, '=', 1)]</field>
            <field name="groups" eval="[(4, ref('group_benefit_manager')),(4, ref('group_benefit_supervisor')),(4, ref('group_family_services_manager'))]"/>
            <field name="active" eval="True" />
        </record>

        <record id="visit_location_rule_branch_manager" model="ir.rule">
            <field name="name">Show Visit Location of Own Branch</field>
            <field name="model_id" ref="model_visit_location"/>
            <field name="domain_force">[('benefit_id.branch_custom_id.branch.manager_id', '=', user.employee_id.id)]</field>
            <field name="groups" eval="[(4, ref('group_benefit_branch_manager'))]"/>
            <field name="active" eval="True" />
        </record>

        <record id="visit_location_rule_operation_manager" model="ir.rule">
            <field name="name">Show Visit Location of Assigned Branch (Operation Manager)</field>
            <field name="model_id" ref="model_visit_location"/>
            <field name="domain_force">[('benefit_id.branch_custom_id.branch.operation_manager_id', '=', user.employee_id.id)]</field>
            <field name="groups" eval="[(4, ref('group_benefit_woman_commitee'))]"/>
            <field name="active" eval="True" />
        </record>

        <record id="visit_location_rule_researcher" model="ir.rule">
            <field name="name">Show Visit Location Created or Assigned (Researcher)</field>
            <field name="model_id" ref="model_visit_location"/>
            <field name="domain_force">[
                '|','|',
                ('create_uid','=',user.id),
                ('benefit_id.assigned_researcher_id.employee_id','in', user.employee_id.ids),
                ('researcher_team.employee_id','in', user.employee_id.ids)
                ]</field>
            <field name="groups" eval="[(4, ref('group_benefit_researcher'))]"/>
            <field name="active" eval="True" />
        </record>

        <record id="survey_user_input_rule_group_benefit_info" model="ir.rule">
            <field name="name">Survey user input: Group Benefit Info</field>
            <field name="model_id" ref="survey.model_survey_user_input"/>
            <field name="domain_force">[(1, '=', 1)]</field>
            <field name="groups" eval="[(4, ref('odex_benefit.group_benefit_info'))]"/>
            <field name="perm_read" eval="True"/>
            <field name="perm_write" eval="False"/>
            <field name="perm_create" eval="False"/>
            <field name="perm_unlink" eval="False"/>
        </record>

        <!-- Add rules for family.complaints -->
        <record id="family_complaints_show_all_rule" model="ir.rule">
            <field name="name">Show All Family Complaints</field>
            <field name="model_id" ref="model_family_complaints"/>
            <field name="domain_force">[(1, '=', 1)]</field>
            <field name="groups" eval="[(4, ref('group_benefit_manager')),(4, ref('group_benefit_supervisor')),(4, ref('group_family_services_manager'))]"/>
            <field name="active" eval="True" />
        </record>

        <record id="family_complaints_rule_branch_manager" model="ir.rule">
            <field name="name">Show Family Complaints of Own Branch</field>
            <field name="model_id" ref="model_family_complaints"/>
            <field name="domain_force">[('branch_custom_id.branch.manager_id', '=', user.employee_id.id)]</field>
            <field name="groups" eval="[(4, ref('group_benefit_branch_manager'))]"/>
            <field name="active" eval="True" />
        </record>

        <record id="family_complaints_rule_operation_manager" model="ir.rule">
            <field name="name">Show Family Complaints of Assigned Branch (Operation Manager)</field>
            <field name="model_id" ref="model_family_complaints"/>
            <field name="domain_force">[('branch_custom_id.branch.operation_manager_id', '=', user.employee_id.id)]</field>
            <field name="groups" eval="[(4, ref('group_benefit_woman_commitee'))]"/>
            <field name="active" eval="True" />
        </record>

        <record id="family_complaints_rule_researcher" model="ir.rule">
            <field name="name">Show Family Complaints Created or Assigned (Researcher)</field>
            <field name="model_id" ref="model_family_complaints"/>
            <field name="domain_force">[
                '|','|',
                ('create_uid','=',user.id),
                ('family_id.assigned_researcher_id.employee_id','in', user.employee_id.ids),
                ('researcher_id.employee_id', 'in', user.employee_id.ids)
                ]</field>
            <field name="groups" eval="[(4, ref('group_benefit_researcher'))]"/>
            <field name="active" eval="True" />
        </record>

        <!-- Add rules for service.request -->
        <record id="service_request_restrict_all_requests_by_rule" model="ir.rule">
            <field name="name">Show All Service Requests</field>
            <field name="model_id" ref="model_service_request"/>
            <field name="domain_force">[(1, '=', 1)]</field>
            <field name="groups" eval="[(4, ref('group_benefit_supervisor')),(4, ref('group_benefit_accountant_accept')),(4, ref('group_benefit_payment_accountant_accept'))]"/>
            <field name="active" eval="True"/>
        </record>

        <record id="service_request_restrict_only_created_by_rule" model="ir.rule">
            <field name="name">Show Service Requests That Own</field>
            <field name="model_id" ref="model_service_request"/>
            <field name="domain_force">[
                '|','|',
                ('create_uid','=',user.id),
                ('family_id.assigned_researcher_id.employee_id','in', user.employee_id.ids),
                ('researcher_id.employee_id', 'in', user.employee_id.ids)
                ]</field>
            <field name="groups" eval="[(4, ref('group_benefit_researcher'))]"/>
            <field name="active" eval="True" />
        </record>

        <record id="service_request_restrict_only_his_branch_rule" model="ir.rule">
            <field name="name">Show Service Requests That Own</field>
            <field name="model_id" ref="model_service_request"/>
            <field name="domain_force">[
                '|',
                ('family_id.branch_custom_id.branch.manager_id', '=', user.employee_id.id),
                ('family_id.branch_custom_id.branch.operation_manager_id', '=', user.employee_id.id)
                ]</field>
            <field name="groups" eval="[(4, ref('group_benefit_branch_manager')), (4, ref('group_benefit_woman_commitee'))]"/>
            <field name="active" eval="True" />
        </record>

        <record id="service_request_rule_legal_department" model="ir.rule">
            <field name="name">Service Requests - Legal Department</field>
            <field name="model_id" ref="model_service_request"/>
            <field name="groups" eval="[(4, ref('odex_benefit.group_service_legal_department'))]"/>
            <field name="domain_force">[('service_cat.needs_legal_approval', '=', True)]</field>
            <field name="active" eval="True"/>
        </record>

        <!-- Add rules for family.member -->
        <record id="family_member_show_all_rule" model="ir.rule">
            <field name="name">Show All Family Members</field>
            <field name="model_id" ref="model_family_member"/>
            <field name="domain_force">[(1, '=', 1)]</field>
            <field name="groups" eval="[(4, ref('group_benefit_manager')),(4, ref('group_benefit_supervisor')),(4, ref('group_family_services_manager'))]"/>
            <field name="active" eval="True" />
        </record>

        <record id="family_member_rule_branch_manager" model="ir.rule">
            <field name="name">Show Family Members of Own Branch</field>
            <field name="model_id" ref="model_family_member"/>
            <field name="domain_force">[('benefit_id.branch_custom_id.branch.manager_id', '=', user.employee_id.id)]</field>
            <field name="groups" eval="[(4, ref('group_benefit_branch_manager'))]"/>
            <field name="active" eval="True" />
        </record>

        <record id="family_member_rule_operation_manager" model="ir.rule">
            <field name="name">Show Family Members of Assigned Branch (Operations Manager)</field>
            <field name="model_id" ref="model_family_member"/>
            <field name="domain_force">[('benefit_id.branch_custom_id.branch.operation_manager_id', '=', user.employee_id.id)]</field>
            <field name="groups" eval="[(4, ref('group_benefit_woman_commitee'))]"/>
            <field name="active" eval="True" />
        </record>

        <record id="family_member_rule_researcher" model="ir.rule">
            <field name="name">Show Family Members Created or Assigned (Researcher)</field>
            <field name="model_id" ref="model_family_member"/>
            <field name="domain_force">['|','|', ('create_uid','=',user.id),
                ('benefit_id.assigned_researcher_id.employee_id','in', user.employee_id.ids),
                ('benefit_id.researcher_id.employee_id', 'in', user.employee_id.ids)]</field>
            <field name="groups" eval="[(4, ref('group_benefit_researcher'))]"/>
            <field name="active" eval="True" />
        </record>

        <record id="benefit_expense_line_rule_researcher" model="ir.rule">
            <field name="name">Show Bank Return Line Assigned To Researcher</field>
            <field name="model_id" ref="model_benefit_expense_line"/>
            <field name="domain_force">['|',
                ('family_id.assigned_researcher_id.employee_id','in', user.employee_id.ids),
                ('family_id.researcher_id.employee_id', 'in', user.employee_id.ids)]</field>
            <field name="groups" eval="[(4, ref('group_benefit_researcher'))]"/>
            <field name="active" eval="True" />
        </record>

        <record id="benefit_expense_line_rule_all" model="ir.rule">
            <field name="name">Show All Bank Return Line</field>
            <field name="model_id" ref="model_benefit_expense_line"/>
            <field name="domain_force">[(1, '=', 1)]</field>
            <field name="groups" eval="[(4, ref('group_benefit_manager')),(4, ref('group_benefit_supervisor')),(4, ref('group_family_services_manager'))]"/>
            <field name="active" eval="True" />
        </record>

        <record id="benefit_expense_line_rule_branch_manager" model="ir.rule">
            <field name="name">Show Bank Return Line of Own Branch</field>
            <field name="model_id" ref="model_benefit_expense_line"/>
            <field name="domain_force">[('branch_id.branch.manager_id', '=', user.employee_id.id)]</field>
            <field name="groups" eval="[(4, ref('group_benefit_branch_manager'))]"/>
            <field name="active" eval="True" />
        </record>
    </data>
</odoo>
