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

      <record id="view_hr_evaluation_plan_search" model="ir.ui.view">
            <field name="name">hr_evaluation.plan.search</field>
            <field name="model">hr_evaluation.plan</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Search Evaluation Plan">
                   <group col='15' colspan='4'>
                       <field name="name"/>
                       <field name="company_id" widget="selection" groups="base.group_multi_company"/>
                   </group>
                   <newline/>
                   <group expand="0" string="Group By..." groups="base.group_multi_company">
                        <filter string="Company" icon="terp-go-home" domain="[]" context="{'group_by':'company_id'}"/>
                    </group>
               </search>
            </field>
        </record>

        <record model="ir.ui.view" id="view_hr_evaluation_plan_form">
            <field name="name">hr_evaluation.plan.form</field>
            <field name="model">hr_evaluation.plan</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Evaluation Plan">
                    <group col="8" colspan="4">
                        <field name="name" select="1"/>
                        <field name="company_id" select="1" widget="selection" groups="base.group_multi_company"/>
                        <field name="month_first"/>
                        <field name="month_next"/>
                        <label string="(months)" align="0.0"/>
                        <newline/>
                        <field name="active"/>
                    </group>
                     <notebook colspan="4">
                         <page string="Evaluation Phases">
                            <field name="phase_ids" nolabel="1" colspan="4"/>
                         </page>
                     </notebook>
                </form>
            </field>
        </record>
        <record model="ir.ui.view" id="view_hr_evaluation_plan_tree">
            <field name="name">hr_evaluation.plan.form</field>
            <field name="model">hr_evaluation.plan</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Evaluation Plan">
                    <field name="name"/>
                    <field name="month_first"/>
                    <field name="month_next"/>
                    <field name="company_id" groups="base.group_multi_company"/>
                </tree>
            </field>
        </record>
        <record model="ir.actions.act_window" id="open_view_hr_evaluation_plan_tree">
            <field name="name">Evaluation Plans</field>
            <field name="res_model">hr_evaluation.plan</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
        </record>

        <menuitem name="Evaluations" parent="hr.menu_hr_root" id="menu_eval_hr" sequence="6"/>
        <menuitem name="Periodic Evaluations" parent="hr.menu_hr_configuration" id="menu_eval_hr_config" sequence="4"/>
        <menuitem parent="menu_eval_hr_config" id="menu_open_view_hr_evaluation_plan_tree"
            action="open_view_hr_evaluation_plan_tree"/>

        <record model="ir.ui.view" id="view_hr_evaluation_plan_phase_form">
            <field name="name">hr_evaluation.plan.phase.form</field>
            <field name="model">hr_evaluation.plan.phase</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Evaluation Plan Phases">
                 <notebook>
                   <page string="General">
                    <field name="plan_id" invisible="1"/>
                    <group col="8" colspan="4">
                        <field name="name"/>
                        <field name="wait"/>
                        <field name="sequence"/>
                    </group>
                    <group col="4" colspan="4">
                        <separator string="Action to Perform" colspan="4"/>
                        <field name="action"/>
                        <field name="survey_id" domain="[('state','=','open')]"/>
                    </group>
                    <group col="4" colspan="4">
                        <group col="4" colspan="2">
                            <separator string="Send to Managers" colspan="2"/>
                            <newline/>
                            <field name="send_answer_manager"/>
                            <newline/>
                            <field name="send_anonymous_manager"/>
                        </group>
                        <group col="4" colspan="2">
                            <separator string="Send to Employees" colspan="2"/>
                            <newline/>
                            <field name="send_answer_employee"/>
                            <newline/>
                            <field name="send_anonymous_employee"/>
                        </group>
                    </group>
                    </page>
                    <page string="Mail Settings">
                        <field name="mail_feature" colspan="4"/>
                        <newline/>
                        <separator string="Mail Body"/>
                        <newline/>
                        <field name="mail_body" colspan="4" nolabel="1"/>
                        <newline/>
                        <separator string="Legend" colspan ="4"/>
                          <label string=" (employee_name)s: Partner name" colspan="2"/>
                          <label string="(user_signature)s: User name" colspan="2"/>
                          <label string="(date)s: Current Date" colspan="2"/>
                          <label string="(eval_name)s:Evaluation Name" colspan="2"/>
                    </page>
                  </notebook>
                </form>
            </field>
        </record>
        <record model="ir.ui.view" id="view_hr_evaluation_plan_phase_tree">
            <field name="name">hr_evaluation.plan.phase.form</field>
            <field name="model">hr_evaluation.plan.phase</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Evaluation Plan Phases" editable="bottom" >
                    <field name="sequence"/>
                    <field name="name"/>
                    <field name="action"/>
                    <field name="survey_id"/>
                    <field name="wait"/>
                </tree>
            </field>
        </record>

        <record id="hr_hr_employee_view_form" model="ir.ui.view">
            <field name="name">hr.hr.employee.view.form</field>
            <field name="model">hr.employee</field>
            <field name="inherit_id" ref="hr.view_employee_form"/>
            <field name="arch" type="xml">
                <page string="Notes" position="before">
                    <page string="Evaluation" groups="base.group_hr_user">
                        <field name="evaluation_plan_id" on_change="onchange_evaluation_plan_id(evaluation_plan_id, evaluation_date)"/>
                        <field name="evaluation_date"/>
                    </page>
                </page>
            </field>
        </record>

        <record model="ir.ui.view" id="view_hr_evaluation_form">
            <field name="name">hr_evaluation.evaluation.form</field>
            <field name="model">hr_evaluation.evaluation</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Evaluation">
                    <group col="4" colspan="3">
                        <separator string="Evaluation Data" colspan="4"/>
                        <field name="employee_id" on_change="onchange_employee_id(employee_id)"/>
                        <field name="plan_id"/>
                        <field name="date"/>
                        <field name="progress" widget="progressbar"/>
                    </group>
                    <group col="2" colspan="1">
                        <separator string="Ending Summary" colspan="2"/>
                        <field name="rating" attrs="{'readonly':[('state','&lt;&gt;','progress')],'required':[('state','=','progress')]}"/>
                        <field name="date_close" readonly="1"/>
                    </group>
                    <notebook colspan="4">
                        <page string="Appraisal">
                            <field name="survey_request_ids" context="{'phase_id': phase_id}" nolabel="1" colspan="4" widget="one2many">
                                <form string="Interview Evaluation">
                                    <group col="4" colspan="4">
                                        <field name="survey_id"/>
                                        <group col="2" colspan="2">
                                            <button name="%(survey.action_view_survey_question_message)d" string="Interview Question" type="action" states="waiting_answer,done,cancel" icon="gtk-execute" context="{'survey_id': survey_id, 'response_id': [response], 'response_no':0, 'active' : response,'request' : True, 'object' : 'hr.evaluation.interview', 'cur_id' : active_id}" attrs="{'readonly':[('survey_id','=',False)]}"/>
                                            <button name="%(survey.survey_browse_response)d" string="Print Interview" type="action" states="done" icon="gtk-print" context="{'survey_id': survey_id, 'response_id' : [response], 'response_no':0,}" attrs="{'readonly':[('response','=',False)]}" />
                                        </group>
                                        <field name="date_deadline"/>
                                        <field name="response" readonly="1"/>
                                        <field name="user_to_review_id"/>
                                        <field name="user_id" string="Interviewer"/>
                                    </group>
                                    <newline/>
                                    <separator string="State" colspan="4"/>
                                    <group colspan="4" col="6">
                                         <field name="state"/>
                                    </group>
                                </form>
                            </field>
                        </page>
                        <page string="Internal Notes">
                            <field name="note_action" colspan="4" nolabel="1"
                                groups="base.group_hr_manager"/>
                        </page>
                        <page string="Public Notes">
                            <field name="note_summary" colspan="4" nolabel="1"/>
                        </page>
                    </notebook>
                    <newline/>
                    <group col="8" colspan="4">
                        <field name="state"/>
                        <button name="button_cancel" string="Cancel" states="draft,wait,progress" type="object"
                                icon="gtk-cancel"/>
                        <button name="button_plan_in_progress" string="Start Evaluation" states="draft" type="object"
                                icon="gtk-execute"/>
                        <button name="button_done" string="Done" states="progress" type="object"
                                icon="gtk-jump-to"/>
                        <button name="button_draft" string="Reset to Draft" states="cancel" type="object"
                                icon="terp-stock_effects-object-colorize"/>
                        <button name="button_final_validation" string="Validate Evaluation" states="wait" type="object"
                                icon="gtk-go-forward"/>
                    </group>
              </form>
            </field>
        </record>

        <record model="ir.ui.view" id="view_hr_evaluation_tree">
            <field name="name">hr_evaluation.evaluation.tree</field>
            <field name="model">hr_evaluation.evaluation</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree colors="blue:state in ('draft');black:state in ('wait','progress');gray:state in('done','cancel')" string="Evaluation">
                    <field name="employee_id"/>
                    <field name="plan_id"/>
                    <field name="date"/>
                    <!--field name="progress" widget="progressbar"/-->
                    <field name="rating"/>
                    <field name="state"/>
                </tree>
            </field>
        </record>

        <record model="ir.ui.view" id="view_hr_evaluation_graph">
            <field name="name">hr_evaluation.evaluation.graph</field>
            <field name="model">hr_evaluation.evaluation</field>
            <field name="type">graph</field>
            <field name="arch" type="xml">
                <graph string="Evaluation" type="bar">
                    <field name="employee_id"/>
                    <field name="progress"  operator="+"/>
                </graph>
            </field>
        </record>

       <record id="hr_evaluation.evaluation_search" model="ir.ui.view">
            <field name="name">hr_evaluation.evaluation_search</field>
            <field name="model">hr_evaluation.evaluation</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Search Evaluation">
                   <group col='10' colspan='4'>
                    <filter icon="terp-check" string="Current" domain="[('state','=','wait')]" help="Evaluations that are in waiting state"/>
                    <filter icon="terp-camera_test" string="In progress" domain="[('state','=','progress')]" help="Evaluations that are in progress state"/>
                    <separator orientation="vertical"/>
                    <filter icon="terp-go-week" string="7 Days" help="Evaluations to close within the next 7 days"
                        domain="[('date', '&gt;=', (datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]" />
                    <separator orientation="vertical"/>
                    <filter icon="terp-gnome-cpu-frequency-applet+" string="Late"
                        help="Evaluations that overpassed the deadline" domain="[('date','&lt;=',(datetime.date.today()).strftime('%%Y-%%m-%%d'))]" />
                    <separator orientation="vertical"/>
                    <field name="employee_id" />
                    <field name="plan_id" widget="selection" />
                    </group>
                    <newline/>
                    <group expand='0' string='Group by...'>
                    <filter string='Employee' icon="terp-personal" domain="[]" context="{'group_by' : 'employee_id'}" />
                    <separator orientation="vertical"/>
                    <filter string='Plan' icon="terp-stock_align_left_24" domain="[]" context="{'group_by' : 'plan_id'}" />
                    <filter string='State' icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by' : 'state'}" />
                    <separator orientation="vertical"/>
                    <filter string='Date' icon="terp-go-month" domain="[]" context="{'group_by' : 'date'}" />
                   </group>
               </search>
            </field>
        </record>

        <record model="ir.actions.act_window" id="open_view_hr_evaluation_tree">
            <field name="name">Evaluations</field>
            <field name="res_model">hr_evaluation.evaluation</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form,graph</field>
            <field name="search_view_id" ref="hr_evaluation.evaluation_search"/>
            <field name="help">Each employee may be assigned an evaluation plan. Such a plan defines the frequency and the way you manage your periodic personnel evaluation. You will be able to define steps and attach interviews to each step. OpenERP manages all kind of evaluations: bottom-up, top-down, self-evaluation and final evaluation by the manager.</field>
        </record>

        <menuitem name="Evaluations" parent="menu_eval_hr" id="menu_open_view_hr_evaluation_tree"
            action="open_view_hr_evaluation_tree"/>

        <record model="ir.ui.view" id="view_hr_evaluation_interview_form">
            <field name="name">hr_evaluation.interview.form</field>
            <field name="model">hr.evaluation.interview</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Interview Evaluation">
                    <group col="4" colspan="4">
                        <field name="survey_id"/>
                        <field name="evaluation_id"/>
                        <group col="2" colspan="2">
                            <button name="%(survey.action_view_survey_question_message)d" string="Interview Question" type="action" states="waiting_answer,done,cancel" icon="gtk-execute" context="{'survey_id': survey_id, 'response_id': [response], 'response_no':0, 'active' : response,'request' : True, 'object' : 'hr.evaluation.interview', 'cur_id' : active_id}" attrs="{'readonly':[('survey_id','=',False)]}"/>
                            <button name="%(survey.survey_browse_response)d" string="Print Interview" type="action" states="done" icon="gtk-print" context="{'survey_id': survey_id, 'response_id' : [response], 'response_no':0,}" attrs="{'readonly':[('response','=',False)]}" />
                        </group>
                        <field name="date_deadline"/>
                        <field name="response" readonly="1"/>
                        <field name="user_to_review_id"/>
                        <field name="user_id" string="Interviewer"/>
                    </group>
                    <newline/>
                    <separator string="State" colspan="4"/>
                    <group colspan="4" col="6">
                         <field name="state"/>
                    </group>
                </form>
            </field>
        </record>

        <record model="ir.ui.view" id="view_hr_evaluation_interview_tree">
            <field name="name">hr_evaluation.interview.tree</field>
            <field name="model">hr.evaluation.interview</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Interview Evaluation">
                    <field name="date_deadline" string="Deadline Date"/>
                    <field name="survey_id"/>
                    <field name="user_id" string="Interviewer"/>
                    <field name="user_to_review_id"/>
                    <field name="response" readonly="1" invisible="True"/>
                    <button name="%(survey.action_view_survey_question_message)d" string="Interview Question" type="action" states="waiting_answer,done,cancel" icon="gtk-execute" context="{'survey_id': survey_id, 'response_id': [response], 'response_no':0, 'active' : response, 'request' : True, 'object' : 'hr.evaluation.interview', 'cur_id' : active_id}" attrs="{'readonly':[('survey_id','=',False)]}"/>
                    <button name="%(survey.survey_browse_response)d" string="Print Interview" type="action" states="done" icon="gtk-print" context="{'survey_id': survey_id, 'response_id' : [response], 'response_no':0}" attrs="{'readonly':[('response','=',False)]}" />
                    <field name="state"/>
                </tree>
            </field>
        </record>

       <record id="view_hr_evaluation_interview_search" model="ir.ui.view">
            <field name="name">view_hr_evaluation_interview_search</field>
            <field name="model">hr.evaluation.interview</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Search Evaluation">
                   <group col='10' colspan='4'>
                        <filter icon="terp-gtk-go-back-rtl" string="To Do" name="todo" domain="[('state','=','waiting_answer')]"/>
                        <separator orientation="vertical"/>
                        <filter icon="terp-gnome-cpu-frequency-applet+" string="Late" domain="[('date_deadline','&lt;',current_date)]"/>
                        <separator orientation="vertical"/>
                        <field name="user_to_review_id"/>
                        <field name="user_id" string="Interviewer"/>
                   </group>
                   <newline/>
                    <group expand="0" string="Group By...">
                        <filter string="Interviewer" icon="terp-personal" domain="[]" context="{'group_by':'user_id'}"/>
                        <separator orientation="vertical"/>
                        <filter string="Survey" icon="terp-stock_align_left_24" domain="[]" context="{'group_by':'survey_id'}"/>
                        <separator orientation="vertical"/>
                        <filter string="State" name="group_state" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>
                    </group>
               </search>
            </field>
        </record>

        <record id="view_evaluation_calendar" model="ir.ui.view">
            <field name="name">Interview Request</field>
            <field name="model">hr.evaluation.interview</field>
            <field name="type">calendar</field>
            <field name="arch" type="xml">
                <calendar string="Interview Request" color="user_to_review_id" date_start="date_deadline">
                    <field name="request_id"/>
                </calendar>
            </field>
        </record>

        <record model="ir.actions.act_window" id="action_hr_evaluation_interview_tree">
            <field name="name">Interview Requests</field>
            <field name="res_model">hr.evaluation.interview</field>
            <field name="view_type">form</field>
            <field name="view_id" ref="view_hr_evaluation_interview_form"/>
            <field name="domain">[('is_evaluation' ,'=', True)]</field>
            <field name="context">{"search_default_todo":1,"search_default_user_id":uid}</field>
            <field name="search_view_id" ref="view_hr_evaluation_interview_search"/>
            <field name="help">Interview Requests are generated automatically by OpenERP according to an employee's evaluation plan. Each user receives automatic emails and requests to evaluate their colleagues periodically.</field>
        </record>

        <record model="ir.actions.act_window.view" id="hr_evaluation_interview_tree">
            <field name="sequence" eval="1"/>
            <field name="view_mode">tree</field>
            <field name="view_id" ref="view_hr_evaluation_interview_tree"/>
            <field name="act_window_id" ref="action_hr_evaluation_interview_tree"/>
        </record>
        <record model="ir.actions.act_window.view" id="hr_evaluation_interview_form">
            <field name="sequence" eval="2"/>
            <field name="view_mode">form</field>
            <field name="view_id" ref="view_hr_evaluation_interview_form"/>
            <field name="act_window_id" ref="action_hr_evaluation_interview_tree"/>
        </record>
        <record model="ir.actions.act_window.view" id="action_view_evaluation_calendar">
            <field name="sequence" eval="3"/>
            <field name="view_mode">calendar</field>
            <field name="view_id" ref="view_evaluation_calendar"/>
            <field name="act_window_id" ref="action_hr_evaluation_interview_tree"/>
        </record>

        <menuitem name="Interview Requests" parent="menu_eval_hr" id="menu_open_hr_evaluation_interview_requests"
            action="action_hr_evaluation_interview_tree"/>
        <menuitem name="Evaluation Reminders" parent="menu_eval_hr" id="menu_eval_send_mail"
           action="action_hr_evaluation_send_mail" sequence="45" groups="base.group_hr_manager"/>

      <!-- Evaluation Interviews Button on Employee Form -->
      <act_window
      context="{'search_default_user_to_review_id': [active_id], 'default_user_to_review_id': active_id}"
      id="act_hr_employee_2_hr__evaluation_interview"
      name="Evaluation Interviews"
      res_model="hr.evaluation.interview"
      src_model="hr.employee"/>

    </data>
</openerp>
