<?xml version="1.0"?>
<openerp>
    <data>
        <menuitem
            id="menu_hr_recruitment_recruitment"
            name="Recruitment"
            parent="hr.menu_hr_configuration"
            sequence="2"/>

    # ------------------------------------------------------
    # Job Categories
    # ------------------------------------------------------

    <record id="hr_job_categ_action" model="ir.actions.act_window">
        <field name="name">Applicant Categories</field>
        <field name="res_model">crm.case.categ</field>
        <field name="view_type">form</field>
        <field name="view_id" ref="crm.crm_case_categ_tree-view"/>
        <field name="domain">[('object_id.model', '=', 'hr.applicant')]</field>
        <field name="context">{'object_id':'hr.applicant'}</field>
    </record>
    # ------------------------------------------------------
    # Stage
    # ------------------------------------------------------
    <record id="hr_job_stage_act" model="ir.actions.act_window">
        <field name="name">Applicant Stages</field>
        <field name="res_model">hr.recruitment.stage</field>
        <field name="view_type">form</field>
        <field name="domain">[]</field>
        <field name="context">{}</field>
    </record>


    # ------------------------------------------------------
    # Jobs
    # ------------------------------------------------------

    <record model="ir.ui.view" id="crm_case_tree_view_job">
        <field name="name">Applicants</field>
        <field name="model">hr.applicant</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="Applicants" colors="grey:state in ('cancel','done');blue:state=='pending'">
                <field name="create_date"/>
                <field name="partner_name"/>
                <field name="email_from"/>
                <field name="partner_phone"/>
                <field name="job_id"/>
                <field name="stage_id"/>
                <button name="stage_previous" string="Previous" states="open,pending" type="object" icon="gtk-go-back"/>
                <button name="stage_next" string="Next" states="open,pending" type="object" icon="gtk-go-forward"/>
                <field name="title_action" invisible="context.get('invisible_next_action', True)"/>
                <field name="date_action" invisible="context.get('invisible_next_date', True)"/>
                <field name="survey" invisible="1"/>
                <field name="response" invisible="1"/>
                <field name="priority"/>
                <field name="type_id" invisible="1"/>
                <field name="availability" invisible="1"/>
                <field name="department_id" invisible="context.get('invisible_department', True)"/>
                <field name="user_id"/>
                <field name="state"/>
                <button name="case_open" string="In Progress" states="draft,pending" type="object" icon="gtk-go-forward"/>
                <button name="case_pending" string="Pending" states="draft,open" type="object" icon="gtk-media-pause"/>
                <button name="case_close" string="Hired" states="open,draft,pending" type="object" icon="terp-partner"/>
                <button name="case_cancel" string="Refused" states="draft,open,pending" type="object" icon="gtk-cancel"/>
            </tree>
        </field>
    </record>

    <record model="ir.ui.view" id="crm_case_form_view_job">
        <field name="name">Jobs - Recruitment Form</field>
        <field name="model">hr.applicant</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form string="Jobs - Recruitment Form">
                <group colspan="4" col="8">
                        <field name="name" string="Subject"/>
                        <field name="partner_name"/>
                        <field name="job_id" on_change="onchange_job(job_id)"/>
                        <button string="Schedule a Phone Call" name="%(action_hr_recruitment_phonecall)d" icon="terp-call-start" type="action" groups="base.group_extended"/>
                        <button name="action_makeMeeting" type="object" string="Schedule Meeting" icon="gtk-index"/>
                    <newline/>
                    <field name="department_id" widget="selection"/>
                    <group colspan="2" col="4">
                        <field name="stage_id" domain="[('department_id','=',department_id)]"/>
                        <button name="stage_previous" string="" type="object" icon="gtk-go-back"/>
                        <button icon="gtk-go-forward" string="" name="stage_next" type="object"/>
                    </group>
                    <field name="user_id"/>
                    <button name="action_print_survey" string="Print Interview" type="object" icon="gtk-print" attrs="{'readonly':[('survey','=',False)]}"/>
                    <button name="%(survey.action_view_survey_question_message)d" string="Interview Question" type="action" icon="gtk-execute" context="{'survey_id': survey, 'response_id': [response], 'response_no':0 ,'active' : response, 'object' : 'hr.applicant', 'cur_id' :active_id}" attrs="{'readonly':[('survey','=',False)]}" groups="base.group_extended"/>
                    <newline/>
          <field name="date_action"/>
          <field name="title_action"/>
                </group>
                <notebook colspan="4">
                    <page string="Job Info">
                        <group col="3" colspan="2">
                            <separator colspan="3" string="Contact"/>
                            <field name="partner_id" on_change="onchange_partner_id(partner_id, email_from)" />
                            <button string="Create Partner"
                                    name="%(action_hr_recruitment_partner_create)d"
                                    icon="gtk-index" type="action" attrs="{'readonly':[('partner_id','!=',False)]}"/>
                            <newline/>
                            <field name="partner_address_id" on_change="onchange_partner_address_id(partner_address_id, email_from)" colspan="3"/>
                            <field name="email_from" colspan="3"/>
                            <field name="partner_phone" colspan="3"/>
                            <field name="partner_mobile" colspan="3"/>
                        </group>
                        <group col="2" colspan="2">
                            <separator colspan="2" string="Contract Data"/>
                            <field name="availability"/>
                            <field name="salary_expected"/>
                            <field name="salary_proposed"/>
                        </group>
                        <group col="2" colspan="2">
                            <separator colspan="2" string="Qualification"/>
                            <!-- <field name="type_id" domain="[('object_id.model', '=', 'hr.applicant')]"/>-->
                            <field name="type_id"/>
                            <field name="priority" string="Appreciation"/>
                            <field name="reference"/>
                        </group>
                        <group col="2" colspan="2">
                           <separator colspan="2" string="Dates"/>
                           <field name="create_date"/>
                           <field name="write_date"/>
                           <field name="date_closed"/>
                           <field name="date_open"/>
                        </group>
                        <separator colspan="4" string="Status"/>
                        <group col="8" colspan="4">
                            <field name="state"/>
                            <button name="case_open" string="In Progress" states="draft,pending" type="object" icon="gtk-go-forward"/>
                            <button name="case_pending" string="Pending" states="draft,open" type="object" icon="gtk-media-pause"/>
                            <button name="case_close" string="Hired" states="open,draft,pending" type="object" icon="terp-partner"/>
                            <button name="case_cancel" string="Refused" states="draft,open,pending" type="object" icon="gtk-cancel"/>
                            <button name="case_reset" string="Reset to New" states="done,cancel" type="object" icon="gtk-convert"/>
                        </group>
                   </page>
                   <page string="Emails" groups="base.group_extended">
                       <group colspan="4">
                           <field colspan="4" name="email_cc" string="Global CC" widget="char"/>
                       </group>
                       <field name="message_ids" colspan="4" nolabel="1" mode="tree,form">
                            <tree string="History">
                                <field name="display_text" string="History Information"/>
                                <field name="history" invisible="1"/>
                                <button
                                    string="Reply" attrs="{'invisible': [('history', '!=', True)]}"
                                    name="%(crm.action_crm_send_mail)d"
                                    context="{'mail':'reply', 'model': 'hr.applicant', 'include_original' : True}"
                                    icon="terp-mail-replied" type="action" />
                            </tree>
                            <form string="History">
                                <group col="4" colspan="4">
                                    <field name="email_from"/>
                                    <field name="date"/>
                                    <field name="email_to" widget="char" size="512"/>
                                    <field name="email_cc" widget="char" size="512"/>
                                    <field name="name" colspan="4" widget="char" size="512"/>
                                    <field name="history" invisible="1"/>
                                </group>
                                <notebook colspan="4">
                                    <page string="Details">
                                        <group attrs="{'invisible': [('history', '!=', True)]}">
                                            <field name="description" colspan="4" nolabel="1" height="250"/>
                                            <button colspan="4"
                                                string="Reply"
                                                name="%(crm.action_crm_send_mail)d"
                                                context="{'mail':'reply', 'model': 'hr.applicant', 'include_original' : True}"
                                                icon="terp-mail-replied" type="action" />
                                        </group>
                                        <group attrs="{'invisible': [('history', '=', True)]}">
                                            <field name="display_text" colspan="4" nolabel="1"  height="250"/>
                                        </group>
                                    </page>
                                    <page string="Attachments">
                                        <field name="attachment_ids" colspan="4" readonly="1" nolabel="1"/>
                                    </page>
                                </notebook>
                            </form>
                        </field>
                         <button string="Add Internal Note"
                                name="%(crm.action_crm_add_note)d"
                                context="{'model': 'crm.lead' }"
                                icon="terp-document-new" type="action" />
                        <button string="Send New Email"
                           name="%(crm.action_crm_send_mail)d"
                           context="{'mail':'new', 'model': 'hr.applicant'}"
                           icon="terp-mail-message-new" type="action" />
                 </page>
                 <page string="Notes">
                     <field name="description" nolabel="1" colspan="4"/>
                 </page>
                </notebook>
            </form>
        </field>
    </record>


    <record model="ir.ui.view" id="crm_case_graph_view_job">
        <field name="name">Jobs - Recruitment Graph</field>
        <field name="model">hr.applicant</field>
        <field name="type">graph</field>
        <field name="arch" type="xml">
              <graph string="Cases By Stage and Estimates" type="bar" orientation="vertical">
                <field name="job_id"/>
                <field name="salary_expected" operator="+"/>
                <field name="state" group="True"/>
            </graph>
        </field>
    </record>

    <record id="view_crm_case_jobs_filter" model="ir.ui.view">
        <field name="name">Jobs - Recruitment Search</field>
        <field name="model">hr.applicant</field>
        <field name="type">search</field>
        <field name="arch" type="xml">
            <search string="Search Jobs">
               <filter icon="terp-check" string="Current"
                   domain="[('state','in',('draft','open'))]"
                   help="All new and in progress jobs"
                   default="1"
                   name="current"
               />
               <filter icon="terp-document-new" string="New"
                   domain="[('state','=','draft')]"
                   help="All Initial Jobs"
               />
               <filter icon="terp-camera_test" string="In Progress"
                   domain="[('state','=','open')]"
                   help="Open Jobs"
               />
               <filter icon="terp-gtk-media-pause" string="Pending"
                   domain="[('state','=','pending')]"
                   help="Pending Jobs"
               />
               <separator orientation="vertical"/>
               <filter icon="terp-gtk-jump-to-ltr" string="Next Actions"
                    context="{'invisible_next_action':False, 'invisible_next_date':False}"
                    domain="[]"
                    help="View Next Action and Date"/>
               <separator orientation="vertical"/>
               <field name="partner_name"/>
               <field name="email_from"/>
               <field name="job_id" widget="selection"/>
               <field name="user_id">
                    <filter domain="[('user_id','=',False)]" help="Unassigned Recruitements" icon="terp-personal-" separator="1"/>
               </field>
               <field name="department_id" widget="selection" string="Department" context="{'invisible_department': False}">
                   <filter icon="terp-personal+" context="{'invisible_department': False}"
                       domain="[('department_id','=',context.get('department_id',False))]"
                       help="My Department"/>
               </field>
               <newline/>
                <group expand="0" string="Group By..." colspan="11" col="20">
                    <filter string="Responsible" icon="terp-personal" domain="[]"  context="{'group_by':'user_id'}"/>
                    <filter string="Department" icon="terp-personal+" domain="[]" context="{'group_by':'department_id'}"/>
                    <separator orientation="vertical"/>
                    <filter string="Job" icon="terp-gtk-select-all" domain="[]" context="{'group_by':'job_id'}"/>
                    <filter string="Degree" icon="terp-gtk-select-all" domain="[]" context="{'group_by':'type_id'}"/>
                    <filter string="Availability" icon="terp-camera_test" domain="[]" context="{'group_by':'availability'}"/>
                    <separator orientation="vertical"/>
                    <filter string="Appreciation" icon="terp-face-plain" domain="[]" context="{'group_by':'priority'}"/>
                    <filter string="Stage" icon="terp-stage" domain="[]" context="{'group_by':'stage_id'}"/>
                    <filter string="State" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>
                    <separator orientation="vertical"/>
                    <filter string="Creation Date" icon="terp-go-month" domain="[]" context="{'group_by':'create_date'}"/>
                </group>
           </search>
        </field>
    </record>

    <!-- CRM Lead Calendar View -->

    <record model="ir.ui.view" id="hr_applicant_calendar_view">
        <field name="name">Hr Applicants Calendar</field>
        <field name="model">hr.applicant</field>
        <field name="type">calendar</field>
        <field name="priority" eval="2"/>
        <field name="arch" type="xml">
            <calendar string="Applicants"
                date_start="date_action" color="user_id">
                <field name="name" />
                <field name="partner_name" />
                <field name="stage_id" />
            </calendar>
        </field>
    </record>


    # ------------------------------------------------------
    # HR Job
    # ------------------------------------------------------

    <record id="hr_job_survey" model="ir.ui.view">
        <field name="name">hr.job.form1</field>
        <field name="model">hr.job</field>
        <field name="type">form</field>
        <field name="inherit_id" ref="hr.view_hr_job_form"/>
        <field name="arch" type="xml">
            <field name="no_of_employee" position="after">
                <field name="survey_id"/>
            </field>
        </field>
    </record>

<!-- Stage Tree View -->

    <record model="ir.ui.view" id="hr_recruitment_stage_tree">
        <field name="name">hr.recruitment.stage.tree</field>
        <field name="model">hr.recruitment.stage</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="Stages">
                <field name="sequence" invisible="1"/>
                <field name="name"/>
                <field name="department_id"/>
            </tree>
        </field>
    </record>

<!-- Stage Form View -->

    <record model="ir.ui.view" id="hr_recruitment_stage_form">
        <field name="name">hr.recruitment.stage.form</field>
        <field name="model">hr.recruitment.stage</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form string="Stage">
                <group colspan="4" col="6">
                    <separator string="Stage Definition" colspan="6"/>
                    <field name="name" select="1"/>
                    <field name="department_id"/>
                    <field name="sequence"/>
                </group>
                <separator string="Requirements" colspan="4"/>
                <field name="requirements" nolabel="1" colspan="4"/>
            </form>
        </field>
    </record>

<!-- Stage Action -->

    <record id="hr_recruitment_stage_act" model="ir.actions.act_window">
        <field name="name">Stages</field>
        <field name="res_model">hr.recruitment.stage</field>
        <field name="view_type">form</field>
        <field name="view_id" ref="hr_recruitment_stage_tree"/>
    </record>

    <menuitem
        id="menu_hr_recruitment_stage"
        name="Stages"
        parent="menu_hr_recruitment_recruitment"
        action="hr_recruitment_stage_act"
        sequence="1"/>

<!-- Degree Tree View -->

    <record model="ir.ui.view" id="hr_recruitment_degree_tree">
        <field name="name">hr.recruitment.degree.tree</field>
        <field name="model">hr.recruitment.degree</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="Degree">
                <field name="sequence" invisible="1"/>
                <field name="name"/>
            </tree>
        </field>
    </record>

<!-- Degree Form View -->

    <record model="ir.ui.view" id="hr_recruitment_degree_form">
        <field name="name">hr.recruitment.degree.form</field>
        <field name="model">hr.recruitment.degree</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form string="Degree">
                    <field name="name" select="1"/>
                    <field name="sequence"/>
            </form>
        </field>
    </record>

<!-- Degree Action -->

    <record id="hr_recruitment_degree_action" model="ir.actions.act_window">
        <field name="name">Degree</field>
        <field name="res_model">hr.recruitment.degree</field>
        <field name="view_type">form</field>
        <field name="view_id" ref="hr_recruitment_degree_tree"/>
    </record>

    </data>
</openerp>
