<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="0">

    <record id="base.group_sale_salesman" model="res.groups">
        <field name="name">See Own Leads</field>
        <field name="category_id" ref="base.module_category_sales_management"/>
        <field name="comment">the user will have access to his own data in the sales application.</field>
        <field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
    </record>

    <record id="base.group_sale_salesman_all_leads" model="res.groups">
        <field name="name">See all Leads</field>
        <field name="category_id" ref="base.module_category_sales_management"/>
        <field name="implied_ids" eval="[(4, ref('base.group_sale_salesman'))]"/>
        <field name="comment">the user will have access to all records of everyone in the sales application.</field>
    </record>

    <record id="base.group_sale_manager" model="res.groups">
        <field name="name">Manager</field>
        <field name="comment">the user will have an access to the sales configuration as well as statistic reports.</field>
        <field name="category_id" ref="base.module_category_sales_management"/>
        <field name="implied_ids" eval="[(4, ref('base.group_sale_salesman_all_leads'))]"/>
        <field name="users" eval="[(4, ref('base.user_root'))]"/>
    </record>

    <record id="group_invoice_so_lines" model="res.groups">
        <field name="name">Enable Invoicing Sales order lines</field>
        <field name="category_id" ref="base.module_category_hidden"/>
    </record>

    <record id="group_delivery_invoice_address" model="res.groups">
        <field name="name">Addresses in Sales Orders</field>
        <field name="category_id" ref="base.module_category_hidden"/>
    </record>

    <record id="group_mrp_properties" model="res.groups">
        <field name="name">Properties on lines</field>
        <field name="category_id" ref="base.module_category_hidden"/>
    </record>

    <record id="group_discount_per_so_line" model="res.groups">
        <field name="name">Discount on lines</field>
        <field name="category_id" ref="base.module_category_hidden"/>
    </record>

    <record id="group_analytic_accounting" model="res.groups">
        <field name="name">Analytic Accounting for Sales</field>
        <field name="category_id" ref="base.module_category_hidden"/>
        <field name="implied_ids" eval="[(4, ref('analytic.group_analytic_accounting'))]"/>
    </record>

    <record model="res.users" id="base.user_root">
        <field eval="[(4,ref('base.group_partner_manager'))]" name="groups_id"/>
    </record>
    <record model="ir.ui.menu" id="base.menu_base_partner">
        <field eval="[(4, ref('base.group_sale_salesman'))]" name="groups_id"/>
    </record>
    <record model="ir.ui.menu" id="base.menu_base_config">
        <field eval="[(4, ref('base.group_sale_manager'))]" name="groups_id"/>
    </record>

</data>
<data noupdate="1">
    <!-- Multi - Company Rules -->

    <record model="ir.rule" id="sale_order_comp_rule">
        <field name="name">Sales Order multi-company</field>
        <field name="model_id" ref="model_sale_order"/>
        <field name="global" eval="True"/>
        <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
    </record>

    <record model="ir.rule" id="sale_order_line_comp_rule">
        <field name="name">Sales Order Line multi-company</field>
        <field name="model_id" ref="model_sale_order_line"/>
        <field name="global" eval="True"/>
        <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
    </record>

    <record model="ir.rule" id="sale_shop_comp_rule">
        <field name="name">Sale Shop multi-company</field>
        <field name="model_id" ref="model_sale_shop"/>
        <field name="global" eval="True"/>
        <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
    </record>

    <!-- Multi - Salesmen sales order assignation rules -->

    <record id="sale_order_personal_rule" model="ir.rule">
        <field name="name">Personal Orders</field>
        <field ref="model_sale_order" name="model_id"/>
        <field name="domain_force">['|',('user_id','=',user.id),('user_id','=',False)]</field>
        <field name="groups" eval="[(4, ref('base.group_sale_salesman'))]"/>
    </record>
    <record id="sale_order_see_all" model="ir.rule">
        <field name="name">All Orders</field>
        <field ref="model_sale_order" name="model_id"/>
        <field name="domain_force">[(1,'=',1)]</field>
        <field name="groups" eval="[(4, ref('base.group_sale_salesman_all_leads'))]"/>
    </record>


    <record id="sale_order_line_personal_rule" model="ir.rule">
        <field name="name">Personal Order Lines</field>
        <field ref="model_sale_order_line" name="model_id"/>
        <field name="domain_force">['|',('order_id.user_id','=',user.id),('order_id.user_id','=',False)]</field>
        <field name="groups" eval="[(4, ref('base.group_sale_salesman'))]"/>
    </record>

    <record id="sale_order_line_see_all" model="ir.rule">
        <field name="name">All Orders Lines</field>
        <field ref="model_sale_order_line" name="model_id"/>
        <field name="domain_force">[(1,'=',1)]</field>
        <field name="groups" eval="[(4, ref('base.group_sale_salesman_all_leads'))]"/>
    </record>

</data>
</openerp>
