<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <!--MultiCompany-->
    <record id="membership_multi_company_record_rule" model="ir.rule">
        <field name="name">Dev Membership Record Rule</field>
        <field name="model_id" ref="dev_membership.model_dev_membership"/>
        <field name="global" eval="True"/>
        <field name="domain_force">['|',('company_id','=',False),('company_id', 'in', company_ids)]
 </field>
    </record>

    <!--Groups-->
    <record model="ir.module.category" id="membership_category">
        <field name="name">Membership</field>
        <field name="sequence">0</field>
    </record>

    <record id="group_membership_user" model="res.groups">
        <field name="name">User</field>
        <field name="category_id" ref="dev_membership.membership_category"/>
    </record>
    <record id="group_membership_manager" model="res.groups">
        <field name="name">Manager</field>
        <field name="implied_ids" eval="[(4, ref('group_membership_user'))]"/>
        <field name="category_id" ref="dev_membership.membership_category"/>
        <field name="users" eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"/>
    </record>
    
    <record id="rule_own_membership_user" model="ir.rule">
        <field name="name">View Own Membership</field>
        <field ref="model_dev_membership" name="model_id"/>
        <field name="domain_force">['|',('user_id','=',user.id),('user_id','=',False)]</field>
        <field name="groups" eval="[(4, ref('group_membership_user'))]"/>
    </record>
    
    <record id="rule_own_membership_manager" model="ir.rule">
        <field name="name">View All Membership</field>
        <field ref="model_dev_membership" name="model_id"/>
        <field name="domain_force">[(1,'=',1)]</field>
        <field name="groups" eval="[(4, ref('group_membership_manager'))]"/>
    </record>

</odoo>
