<?xml version="1.0" ?>
<openerp>
    <data noupdate="0">
        <record model="ir.module.category" id="module_fleet_category">
            <field name="name">Fleet</field>
            <field name="sequence">17</field>
        </record>
        <record id="group_fleet_user" model="res.groups">
            <field name="name">User</field>
            <field name="category_id" ref="module_fleet_category"/>
        </record>
        <record id="group_fleet_manager" model="res.groups">
            <field name="name">Manager</field>
            <field name="implied_ids" eval="[(4, ref('group_fleet_user'))]"/>
            <field name="category_id" ref="module_fleet_category"/>
            <field name="users" eval="[(4, ref('base.user_root'))]"/>
        </record>
    </data>

    <data noupdate="1">
        <record id="fleet_user_contract_visibility" model="ir.rule">
            <field name="name">User can only see his/her contracts</field>
            <field name="model_id" ref="model_fleet_vehicle_log_contract"/>
            <field name="groups" eval="[(4, ref('group_fleet_user'))]"/>
            <field name="perm_read" eval="True"/>
            <field name="perm_write" eval="False"/>
            <field name="perm_create" eval="False"/>
            <field name="perm_unlink" eval="False"/>
            <field name="domain_force">[('cost_id.vehicle_id.driver_id','=',user.partner_id.id)]</field>
        </record>
        <record id="fleet_user_cost_visibility" model="ir.rule">
            <field name="name">User can only see his/her costs</field>
            <field name="model_id" ref="model_fleet_vehicle_cost"/>
            <field name="groups" eval="[(4, ref('group_fleet_user'))]"/>
            <field name="perm_read" eval="True"/>
            <field name="perm_write" eval="True"/>
            <field name="perm_create" eval="True"/>
            <field name="perm_unlink" eval="False"/>
            <field name="domain_force">[('vehicle_id.driver_id','=',user.partner_id.id)]</field>
        </record>
        <record id="fleet_user_service_visibility" model="ir.rule">
            <field name="name">User can only see his/her vehicle's services</field>
            <field name="model_id" ref="model_fleet_vehicle_log_services"/>
            <field name="groups" eval="[(4, ref('group_fleet_user'))]"/>
            <field name="perm_read" eval="True"/>
            <field name="perm_write" eval="False"/>
            <field name="perm_create" eval="False"/>
            <field name="perm_unlink" eval="False"/>
            <field name="domain_force">[('cost_id.vehicle_id.driver_id','=',user.partner_id.id)]</field>
        </record>
        <record id="fleet_user_odometer_visibility" model="ir.rule">
            <field name="name">User can only see his/her vehicle's odometer</field>
            <field name="model_id" ref="model_fleet_vehicle_odometer"/>
            <field name="groups" eval="[(4, ref('group_fleet_user'))]"/>
            <field name="perm_read" eval="True"/>
            <field name="perm_write" eval="True"/>
            <field name="perm_create" eval="True"/>
            <field name="perm_unlink" eval="True"/>
            <field name="domain_force">[('vehicle_id.driver_id','=',user.partner_id.id)]</field>
        </record>
        <record id="fleet_user_fuel_log_visibility" model="ir.rule">
            <field name="name">User can only see his/her vehicle's fuel log</field>
            <field name="model_id" ref="model_fleet_vehicle_log_fuel"/>
            <field name="groups" eval="[(4, ref('group_fleet_user'))]"/>
            <field name="perm_read" eval="True"/>
            <field name="perm_write" eval="True"/>
            <field name="perm_create" eval="True"/>
            <field name="perm_unlink" eval="True"/>
            <field name="domain_force">[('cost_id.vehicle_id.driver_id','=',user.partner_id.id)]</field>
        </record>
        <record id="fleet_user_vehicle_visibility" model="ir.rule">
            <field name="name">User can only see his/her vehicle</field>
            <field name="model_id" ref="model_fleet_vehicle"/>
            <field name="groups" eval="[(4, ref('group_fleet_user'))]"/>
            <field name="perm_read" eval="True"/>
            <field name="perm_write" eval="True"/>
            <field name="perm_create" eval="False"/>
            <field name="perm_unlink" eval="False"/>
            <field name="domain_force">[('driver_id','=',user.partner_id.id)]</field>
        </record>
        <record id="fleet_user_contract_visibility_manager" model="ir.rule">
            <field name="name">Manager has all rights on vehicle's contracts</field>
            <field name="model_id" ref="model_fleet_vehicle_log_contract"/>
            <field name="groups" eval="[(4, ref('group_fleet_manager'))]"/>
        </record>
        <record id="fleet_user_cost_visibility_manager" model="ir.rule">
            <field name="name">Manager has all rights on vehicle's costs</field>
            <field name="model_id" ref="model_fleet_vehicle_cost"/>
            <field name="groups" eval="[(4, ref('group_fleet_manager'))]"/>
        </record>
        <record id="fleet_user_service_visibility_manager" model="ir.rule">
            <field name="name">Manager has all rights on vehicle's services</field>
            <field name="model_id" ref="model_fleet_vehicle_log_services"/>
            <field name="groups" eval="[(4, ref('group_fleet_manager'))]"/>
        </record>
        <record id="fleet_user_odometer_visibility_manager" model="ir.rule">
            <field name="name">Manager has all rights on vehicle's vehicle's odometer</field>
            <field name="model_id" ref="model_fleet_vehicle_odometer"/>
            <field name="groups" eval="[(4, ref('group_fleet_manager'))]"/>
        </record>
        <record id="fleet_user_fuel_log_visibility_manager" model="ir.rule">
            <field name="name">Manager has all rights on vehicle's fuel log</field>
            <field name="model_id" ref="model_fleet_vehicle_log_fuel"/>
            <field name="groups" eval="[(4, ref('group_fleet_manager'))]"/>
        </record>
        <record id="fleet_user_vehicle_visibility_manager" model="ir.rule">
            <field name="name">Manager has all rights on vehicle</field>
            <field name="model_id" ref="model_fleet_vehicle"/>
            <field name="groups" eval="[(4, ref('group_fleet_manager'))]"/>
        </record>

    </data>
</openerp>
