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

    <!-- Manager Read Rule -->
    <record id="rule_git_project_rel_manager_read" model="ir.rule">
        <field name="name">Git Project Relation: Manager Read Access</field>
        <field name="model_id" ref="model_cx_tower_git_project_rel" />
        <field name="domain_force">['&amp;',
            '|',
                ('git_project_id.user_ids', 'in', [user.id]),
                ('git_project_id.manager_ids', 'in', [user.id]),
            '|',
                ('server_id.user_ids', 'in', [user.id]),
                ('server_id.manager_ids', 'in', [user.id])]</field>
        <field name="groups" eval="[(4, ref('cetmix_tower_server.group_manager'))]" />
        <field name="perm_read" eval="1" />
        <field name="perm_write" eval="0" />
        <field name="perm_create" eval="0" />
        <field name="perm_unlink" eval="0" />
    </record>

    <!-- Manager Write/Create/Delete Rule -->
    <record id="rule_git_project_rel_manager_create_write_unlink" model="ir.rule">
        <field
            name="name"
        >Git Project Relation: Manager Create/Write/Delete Access</field>
        <field name="model_id" ref="model_cx_tower_git_project_rel" />
        <field name="domain_force">[('git_project_id.manager_ids', 'in', [user.id]),
                                  ('server_id.manager_ids', 'in', [user.id])]</field>
        <field name="groups" eval="[(4, ref('cetmix_tower_server.group_manager'))]" />
        <field name="perm_read" eval="0" />
        <field name="perm_write" eval="1" />
        <field name="perm_create" eval="1" />
        <field name="perm_unlink" eval="1" />
    </record>

    <!-- Root Access Rule -->
    <record id="rule_git_project_rel_root" model="ir.rule">
        <field name="name">Git Project Relation: Root Full Access</field>
        <field name="model_id" ref="model_cx_tower_git_project_rel" />
        <field name="domain_force">[(1, '=', 1)]</field>
        <field name="groups" eval="[(4, ref('cetmix_tower_server.group_root'))]" />
    </record>

</odoo>
