[REV] hr_recruitment: continuing reverting most changes, reparing analysis views.
authorThibault Delavallée <tde@openerp.com>
Wed, 23 Oct 2013 11:55:05 +0000 (13:55 +0200)
committerThibault Delavallée <tde@openerp.com>
Wed, 23 Oct 2013 11:55:05 +0000 (13:55 +0200)
bzr revid: tde@openerp.com-20131023115505-k4eqt1jo5w0ruo4o

addons/hr_recruitment/hr_recruitment.py
addons/hr_recruitment/hr_recruitment_data.xml
addons/hr_recruitment/hr_recruitment_view.xml
addons/hr_recruitment/report/hr_recruitment_report.py

index 2e22a76..780c439 100644 (file)
@@ -56,10 +56,6 @@ class hr_recruitment_stage(osv.osv):
         'fold': fields.boolean('Folded in Kanban View',
                                help='This stage is folded in the kanban view when'
                                'there are no records in that stage to display.'),
-        'closed': fields.boolean('Closing Stage',
-                                 help='Indicates whether this field is the end of'
-                                 'the maangement process. This is for example a'
-                                 'stage considering the applicant as hired or refused.'),
     }
     _defaults = {
         'sequence': 1,
@@ -87,8 +83,9 @@ class hr_applicant(osv.Model):
     _inherit = ['mail.thread', 'ir.needaction_mixin']
     _track = {
         'stage_id': {
-            'hr_recruitment.mt_applicant_new': lambda self, cr, uid, obj, ctx=None: obj.stage_id and obj.stage_id.sequence == 1,
-            'hr_recruitment.mt_applicant_stage_changed': lambda self, cr, uid, obj, ctx=None: obj.stage_id and obj.stage_id.sequence != 1,
+            # this is only an heuristics; depending on your particular stage configuration it may not match all 'new' stages
+            'hr_recruitment.mt_applicant_new': lambda self, cr, uid, obj, ctx=None: obj.stage_id and obj.stage_id.sequence <= 1,
+            'hr_recruitment.mt_applicant_stage_changed': lambda self, cr, uid, obj, ctx=None: obj.stage_id and obj.stage_id.sequence > 1,
         },
     }
 
@@ -99,7 +96,7 @@ class hr_applicant(osv.Model):
     def _get_default_stage_id(self, cr, uid, context=None):
         """ Gives default stage_id """
         department_id = self._get_default_department_id(cr, uid, context=context)
-        return self.stage_find(cr, uid, [], department_id, [('sequence', '=', '1')], context=context)
+        return self.stage_find(cr, uid, [], department_id, [('fold', '=', False)], context=context)
 
     def _resolve_department_id_from_context(self, cr, uid, context=None):
         """ Returns ID of department based on the value of 'default_department_id'
@@ -246,7 +243,7 @@ class hr_applicant(osv.Model):
 
     def onchange_department_id(self, cr, uid, ids, department_id=False, stage_id=False, context=None):
         if not stage_id:
-            stage_id = self.stage_find(cr, uid, [], department_id, [('sequence', '=', '1')], context=context)
+            stage_id = self.stage_find(cr, uid, [], department_id, [('fold', '=', False)], context=context)
         return {'value': {'stage_id': stage_id}}
 
     def onchange_partner_id(self, cr, uid, ids, partner_id, context=None):
index 6279d88..219f364 100644 (file)
     <record model="hr.recruitment.stage" id="stage_job5">
         <field name="name">Contract Signed</field>
         <field name="sequence">5</field>
-        <field name="closed" eval="True"/>
+        <field name="fold" eval="True"/>
     </record>
     <record model="hr.recruitment.stage" id="stage_job6">
         <field name="name">Refused</field>
         <field name="sequence">6</field>
         <field name="fold" eval="True"/>
-        <field name="closed" eval="True"/>
     </record>
 
     <record id="survey_job_0" model="survey">
index 912419a..7553a24 100644 (file)
                     <group>
                         <field name="name"/>
                         <field name="department_id"/>
-                        <field name="sequence"/>
                     </group>
                     <group>
+                        <field name="sequence"/>
                         <field name="fold"/>
-                        <field name="closed"/>
                     </group>
                 </group>
                 <separator string="Requirements"/>
index 0292875..908b701 100644 (file)
@@ -90,7 +90,7 @@ class hr_recruitment_report(osv.Model):
                      (sum(salary_proposed)/count(*)) as salary_prop_avg,
                      sum(salary_expected) as salary_exp,
                      (sum(salary_expected)/count(*)) as salary_exp_avg,
-                     extract('epoch' from (s.date_closed-s.create_date))/(3600*24) as delay_close,
+                     extract('epoch' from (s.write_date-s.create_date))/(3600*24) as delay_close,
                      count(*) as nbr
                  from hr_applicant s
                  group by
@@ -101,6 +101,7 @@ class hr_recruitment_report(osv.Model):
                      date_trunc('day',s.date_closed),
                      s.date_open,
                      s.create_date,
+                     s.write_date,
                      s.date_closed,
                      s.date_last_stage_update,
                      s.partner_id,