<?xml version="1.0"?>
<openerp>
    <data noupdate="1">

        <!-- Crm stages -->
        <record model="crm.case.stage" id="stage_lead1">
            <field name="name">New</field>
            <field name="case_default">1</field>
            <field name="probability">0</field>
            <field name="on_change">1</field>
            <field name="sequence">1</field>
            <field name="type">both</field>
        </record>
        <record model="crm.case.stage" id="stage_lead2">
            <field name="name">Dead</field>
            <field name="case_default">1</field>
            <field name="fold">1</field>
            <field name="probability">0</field>
            <field name="on_change">1</field>
            <field name="sequence">30</field>
            <field name="type">lead</field>
        </record>
        <record model="crm.case.stage" id="stage_lead3">
            <field name="name">Qualification</field>
            <field name="case_default">1</field>
            <field name="probability">20</field>
            <field name="on_change">1</field>
            <field name="sequence">40</field>
            <field name="type">opportunity</field>
        </record>
        <record model="crm.case.stage" id="stage_lead4">
            <field name="name">Proposition</field>
            <field name="case_default">1</field>
            <field name="probability">40</field>
            <field name="sequence">50</field>
            <field name="type">opportunity</field>
        </record>
        <record model="crm.case.stage" id="stage_lead5">
            <field name="name">Negotiation</field>
            <field name="case_default">1</field>
            <field name="probability">60</field>
            <field name="sequence">60</field>
            <field name="type">opportunity</field>
        </record>
        <record model="crm.case.stage" id="stage_lead6">
            <field name="name">Won</field>
            <field name="case_default">1</field>
            <field name="fold">1</field>
            <field name="probability">100</field>
            <field name="on_change">1</field>
            <field name="sequence">70</field>
            <field name="type">opportunity</field>
        </record>
        <record model="crm.case.stage" id="stage_lead7">
            <field name="name">Lost</field>
            <field name="case_default">1</field>
            <field name="fold">1</field>
            <field name="probability">0</field>
            <field name="on_change">1</field>
            <field name="sequence">80</field>
            <field name="type">opportunity</field>
        </record>
        
        <record model="crm.case.section" id="sales_team.section_sales_department">
            <field name="stage_ids" eval="[ (4, ref('stage_lead1')), (4, ref('stage_lead2')),
                                            (4, ref('stage_lead3')), (4, ref('stage_lead4')),
                                            (4, ref('stage_lead5')), (4, ref('stage_lead6')),
                                            (4, ref('stage_lead7'))]"/>
        </record>


        <!--  crm categories -->
        <record model="crm.case.categ" id="categ_oppor1">
            <field name="name">Product</field>
            <field name="section_id" ref="sales_team.section_sales_department"/>
            <field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
        </record>
        <record model="crm.case.categ" id="categ_oppor2">
            <field name="name">Software</field>
            <field name="section_id" ref="sales_team.section_sales_department"/>
            <field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
        </record>
        <record model="crm.case.categ" id="categ_oppor3">
            <field name="name">Services</field>
            <field name="section_id" ref="sales_team.section_sales_department"/>
            <field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
        </record>
        <record model="crm.case.categ" id="categ_oppor4">
            <field name="name">Information</field>
            <field name="section_id" ref="sales_team.section_sales_department"/>
            <field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
        </record>
        <record model="crm.case.categ" id="categ_oppor5">
            <field name="name">Design</field>
            <field name="section_id" ref="sales_team.section_sales_department"/>
            <field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
        </record>
        <record model="crm.case.categ" id="categ_oppor6">
            <field name="name">Training</field>
            <field name="section_id" ref="sales_team.section_sales_department"/>
            <field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
        </record>
        <record model="crm.case.categ" id="categ_oppor7">
            <field name="name">Consulting</field>
            <field name="section_id" ref="sales_team.section_sales_department"/>
            <field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
        </record>
        <record model="crm.case.categ" id="categ_oppor8">
            <field name="name">Other</field>
            <field name="section_id" ref="sales_team.section_sales_department"/>
            <field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
        </record>

        <!-- CRM-related subtypes for messaging / Chatter -->
        <record id="mt_lead_create" model="mail.message.subtype">
            <field name="name">Lead Created</field>
            <field name="hidden" eval="True"/>
            <field name="res_model">crm.lead</field>
            <field name="default" eval="False"/>
            <field name="description">Lead created</field>
        </record>
        <record id="mt_lead_stage" model="mail.message.subtype">
            <field name="name">Stage Changed</field>
            <field name="res_model">crm.lead</field>
            <field name="default" eval="False"/>
            <field name="description">Stage changed</field>
        </record>
        <record id="mt_lead_won" model="mail.message.subtype">
            <field name="name">Opportunity Won</field>
            <field name="res_model">crm.lead</field>
            <field name="default" eval="False"/>
            <field name="description">Opportunity won</field>
        </record>
        <record id="mt_lead_lost" model="mail.message.subtype">
            <field name="name">Opportunity Lost</field>
            <field name="res_model">crm.lead</field>
            <field name="default" eval="False"/>
            <field name="description">Opportunity lost</field>
        </record>
        <!-- Salesteam-related subtypes for messaging / Chatter -->
        <record id="mt_salesteam_lead" model="mail.message.subtype">
            <field name="name">Lead Created</field>
            <field name="sequence">10</field>
            <field name="res_model">crm.case.section</field>
            <field name="default" eval="False"/>
            <field name="parent_id" eval="ref('mt_lead_create')"/>
            <field name="relation_field">section_id</field>
        </record>
        <record id="mt_salesteam_lead_stage" model="mail.message.subtype">
            <field name="name">Opportunity Stage Changed</field>
            <field name="sequence">11</field>
            <field name="res_model">crm.case.section</field>
            <field name="parent_id" eval="ref('mt_lead_stage')"/>
            <field name="relation_field">section_id</field>
        </record>
        <record id="mt_salesteam_lead_won" model="mail.message.subtype">
            <field name="name">Opportunity Won</field>
            <field name="sequence">12</field>
            <field name="res_model">crm.case.section</field>
            <field name="parent_id" eval="ref('mt_lead_won')"/>
            <field name="relation_field">section_id</field>
        </record>
        <record id="mt_salesteam_lead_lost" model="mail.message.subtype">
            <field name="name">Opportunity Lost</field>
            <field name="sequence">13</field>
            <field name="res_model">crm.case.section</field>
            <field name="default" eval="False"/>
            <field name="parent_id" eval="ref('mt_lead_lost')"/>
            <field name="relation_field">section_id</field>
        </record>

        <!--Definition of an email template with an empty body that will be used in opportunity mailing.
            Used to give a basis for email recipients, name and to ease the definition of a further
            elaborated template.  -->
        <record id="email_template_opportunity_mail" model="email.template">
            <field name="name">Lead/Opportunity Mass Mail</field>
            <field name="model_id" ref="crm.model_crm_lead"/>
            <field name="auto_delete" eval="True"/>
            <field name="partner_to">${object.partner_id != False and object.partner_id.id}</field>
            <field name="email_to">${(not object.partner_id and object.email_from)|safe}</field>
            <field name="body_html"></field>
        </record>
        <record id="email_template_opportunity_reminder_mail" model="email.template">
            <field name="name">Reminder to User</field>
            <field name="model_id" ref="crm.model_crm_lead"/>
            <field name="auto_delete" eval="True"/>
            <field name="email_from">admin@example.com</field>
            <field name="email_to">${(object.user_id != False and object.user_id.email)|safe}</field>
            <field name="subject">Reminder on Lead: ${object.id} from ${object.partner_id != False and object.partner_id.name or object.contact_name}</field>
            <field name="body_html"><![CDATA[<p>This opportunity did not have any activity since at least 5 days. Here are some details:</p>
<ul>
<li>Name: ${object.name}</li>
<li>ID: ${object.id}</li>
<li>Description: ${object.description}</field></li>
</ul>]]></field>
        </record>

    </data>
</openerp>
