<?xml version="1.0"?>
<openerp>
    <data noupdate="1">
        <!-- demo automated actions add messge on new lead after 5 days -->
        <record id="filter_draft_lead" model="ir.filters">
            <field name="name">Draft Leads</field>
            <field name="model_id">crm.lead</field>
            <field name="domain">[('stage_id.sequence', '=', 1)]</field>
            <field name="user_id" eval="False"/>
        </record>
        <record id="action_email_reminder_lead" model="ir.actions.server">
            <field name="name">Reminder to User</field>
            <field name="model_id" ref="model_crm_lead"/>
            <field name="condition">True</field>
            <field name="type">ir.actions.server</field>
            <field name="state">email</field>
            <field name="template_id" ref="email_template_opportunity_reminder_mail"/>
        </record>
        <record id="rule_set_reminder_lead" model="base.action.rule">
            <field name="name">Set Auto Reminder on leads which are not open since 5 days.</field>
            <field name="model_id" ref="model_crm_lead"/>
            <field name="sequence">1</field>
            <field name="kind">on_time</field>
            <field name="filter_id" ref="filter_draft_lead"/>
            <field name="trg_date_id" ref="field_crm_lead_create_date"/>
            <field name="trg_date_range">5</field>
            <field name="trg_date_range_type">day</field>
            <field name="server_action_ids" eval="[(6,0,[ref('action_email_reminder_lead')])]"/>
        </record>

        <!-- demo automated actions add a followers on urgent USA leads -->
        <record id="filter_usa_lead" model="ir.filters">
            <field name="name">Leads from USA</field>
            <field name="model_id">crm.lead</field>
            <field name="domain">[('country_id','=','United States')]</field>
            <field name="user_id" eval="False"/>
        </record>
        <record id="action_set_team_sales_department" model="ir.actions.server">
            <field name="name">Set team to Sales Department</field>
            <field name="model_id" ref="model_crm_lead"/>
            <field name="condition">True</field>
            <field name="type">ir.actions.server</field>
            <field name="state">code</field>
            <field name="code">sales_team = self.pool.get('ir.model.data').get_object(cr, uid, 'sales_team', 'section_sales_department')
object.write({'section_id': sales_team.id})
            </field>
        </record>
        <record id="rule_set_followers_lead" model="base.action.rule">
            <field name="name">Set Auto Followers on leads which are urgent and come from USA.</field>
            <field name="model_id" ref="model_crm_lead"/>
            <field name="sequence">2</field>
            <field name="kind">on_create</field>
            <field name="filter_id" ref="filter_usa_lead"/>
            <field name="act_user_id" ref="base.user_root"/>
            <field name="act_followers" eval="[(6,0,[ref('base.res_partner_4'), ref('base.res_partner_5'), ref('base.res_partner_6')])]"/>
            <field name="server_action_ids" eval="[(6,0,[ref('action_set_team_sales_department')])]"/>
        </record>
    </data>
</openerp>
