From 9dfa8563ef54a87e7aa8ac3f91b44f1b4dacdd93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 27 Jun 2013 11:48:07 +0200 Subject: [PATCH 01/12] [REF] hr_recruitment: removed base_stage inheritance, state field. Updated views / reports. Still not updated subtypes. bzr revid: tde@openerp.com-20130627094807-8vg21s2w0lqblrza --- .../board_hr_recruitment_statistical_view.xml | 2 +- addons/hr_recruitment/hr_recruitment.py | 71 +++---------------- addons/hr_recruitment/hr_recruitment_data.xml | 23 +++--- addons/hr_recruitment/hr_recruitment_view.xml | 23 ++---- .../report/hr_recruitment_report.py | 15 +--- .../report/hr_recruitment_report_view.xml | 15 ++-- .../test/recruitment_process.yml | 62 +--------------- 7 files changed, 36 insertions(+), 175 deletions(-) diff --git a/addons/hr_recruitment/board_hr_recruitment_statistical_view.xml b/addons/hr_recruitment/board_hr_recruitment_statistical_view.xml index 79e09937705..2bec80858a5 100644 --- a/addons/hr_recruitment/board_hr_recruitment_statistical_view.xml +++ b/addons/hr_recruitment/board_hr_recruitment_statistical_view.xml @@ -22,7 +22,7 @@ hr.applicant form tree,form - [('state','in',('draft','open'))] + [('stage_id.fold', '!=', True)] diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index c25583cba77..4745672179b 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -19,23 +19,13 @@ # ############################################################################## -import time from openerp import tools -from openerp.addons.base_status.base_stage import base_stage from datetime import datetime from openerp.osv import fields, osv from openerp.tools.translate import _ from openerp.tools import html2plaintext -AVAILABLE_STATES = [ - ('draft', 'New'), - ('cancel', 'Refused'), - ('open', 'In Progress'), - ('pending', 'Pending'), - ('done', 'Hired') -] - AVAILABLE_PRIORITIES = [ ('', ''), ('5', 'Not Good'), @@ -62,13 +52,11 @@ class hr_recruitment_stage(osv.osv): 'name': fields.char('Name', size=64, required=True, translate=True), 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of stages."), 'department_id':fields.many2one('hr.department', 'Specific to a Department', help="Stages of the recruitment process may be different per department. If this stage is common to all departments, keep this field empty."), - 'state': fields.selection(AVAILABLE_STATES, 'Status', required=True, help="The related status for the stage. The status of your document will automatically change according to the selected stage. Example, a stage is related to the status 'Close', when your document reach this stage, it will be automatically closed."), 'fold': fields.boolean('Hide in views if empty', help="This stage is not visible, for example in status bar or kanban view, when there are no records in that stage to display."), 'requirements': fields.text('Requirements'), } _defaults = { 'sequence': 1, - 'state': 'draft', 'fold': False, } @@ -87,19 +75,19 @@ class hr_recruitment_degree(osv.osv): ('name_uniq', 'unique (name)', 'The name of the Degree of Recruitment must be unique!') ] -class hr_applicant(base_stage, osv.Model): +class hr_applicant(osv.Model): _name = "hr.applicant" _description = "Applicant" _order = "id desc" _inherit = ['mail.thread', 'ir.needaction_mixin'] _track = { - 'state': { - 'hr_recruitment.mt_applicant_hired': lambda self, cr, uid, obj, ctx=None: obj['state'] == 'done', - 'hr_recruitment.mt_applicant_refused': lambda self, cr, uid, obj, ctx=None: obj['state'] == 'cancel', - }, - 'stage_id': { - 'hr_recruitment.mt_stage_changed': lambda self, cr, uid, obj, ctx=None: obj['state'] not in ['done', 'cancel'], - }, + # 'state': { + # 'hr_recruitment.mt_applicant_hired': lambda self, cr, uid, obj, ctx=None: obj['state'] == 'done', + # 'hr_recruitment.mt_applicant_refused': lambda self, cr, uid, obj, ctx=None: obj['state'] == 'cancel', + # }, + # 'stage_id': { + # 'hr_recruitment.mt_stage_changed': lambda self, cr, uid, obj, ctx=None: obj['state'] not in ['done', 'cancel'], + # }, } def _get_default_department_id(self, cr, uid, context=None): @@ -109,7 +97,7 @@ class hr_applicant(base_stage, 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, [('state', '=', 'draft')], context=context) + return self.stage_find(cr, uid, [], department_id, [('sequence', '=', '1')], 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' @@ -197,13 +185,6 @@ class hr_applicant(base_stage, osv.Model): 'write_date': fields.datetime('Update Date', readonly=True), 'stage_id': fields.many2one ('hr.recruitment.stage', 'Stage', track_visibility='onchange', domain="['|', ('department_id', '=', department_id), ('department_id', '=', False)]"), - 'state': fields.related('stage_id', 'state', type="selection", store=True, - selection=AVAILABLE_STATES, string="Status", readonly=True, - help='The status is set to \'Draft\', when a case is created.\ - If the case is in progress the status is set to \'Open\'.\ - When the case is over, the status is set to \'Done\'.\ - If the case needs to be reviewed then the status is \ - set to \'Pending\'.'), 'categ_ids': fields.many2many('hr.applicant_category', string='Tags'), 'company_id': fields.many2one('res.company', 'Company'), 'user_id': fields.many2one('res.users', 'Responsible', track_visibility='onchange'), @@ -409,20 +390,6 @@ class hr_applicant(base_stage, osv.Model): self.pool.get('hr.job').message_post(cr, uid, [applicant.job_id.id], body=_('Applicant created'), subtype="hr_recruitment.mt_job_new_applicant", context=context) return obj_id - def case_open(self, cr, uid, ids, context=None): - """ - open Request of the applicant for the hr_recruitment - """ - res = super(hr_applicant, self).case_open(cr, uid, ids, context) - date = self.read(cr, uid, ids, ['date_open'])[0] - if not date['date_open']: - self.write(cr, uid, ids, {'date_open': time.strftime('%Y-%m-%d %H:%M:%S'),}) - return res - - def case_close(self, cr, uid, ids, context=None): - res = super(hr_applicant, self).case_close(cr, uid, ids, context) - return res - def case_close_with_emp(self, cr, uid, ids, context=None): if context is None: context = {} @@ -454,26 +421,6 @@ class hr_applicant(base_stage, osv.Model): dict_act_window['view_mode'] = 'form,tree' return dict_act_window - def case_cancel(self, cr, uid, ids, context=None): - """Overrides cancel for crm_case for setting probability - """ - res = super(hr_applicant, self).case_cancel(cr, uid, ids, context) - self.write(cr, uid, ids, {'probability': 0.0}) - return res - - def case_pending(self, cr, uid, ids, context=None): - """Marks case as pending""" - res = super(hr_applicant, self).case_pending(cr, uid, ids, context) - self.write(cr, uid, ids, {'probability': 0.0}) - return res - - def case_reset(self, cr, uid, ids, context=None): - """Resets case as draft - """ - res = super(hr_applicant, self).case_reset(cr, uid, ids, context) - self.write(cr, uid, ids, {'date_open': False, 'date_closed': False}) - return res - def set_priority(self, cr, uid, ids, priority, *args): """Set applicant priority """ diff --git a/addons/hr_recruitment/hr_recruitment_data.xml b/addons/hr_recruitment/hr_recruitment_data.xml index f3f1b3e712d..854dea0548f 100644 --- a/addons/hr_recruitment/hr_recruitment_data.xml +++ b/addons/hr_recruitment/hr_recruitment_data.xml @@ -51,34 +51,29 @@ Doctoral Degree 4 + Initial Qualification - draft 1 First Interview - open 2 Second Interview - open 3 Contract Proposed - pending 4 Contract Signed - done 5 Refused - cancel 6 @@ -467,24 +462,24 @@ hr.job - + + New Applicant + hr.applicant + + Applicant created + + Stage Changed hr.applicant Stage changed - + Applicant Hired hr.applicant Applicant hired - - Applicant Refused - hr.applicant - - Applicant refused - Reserve diff --git a/addons/hr_recruitment/hr_recruitment_view.xml b/addons/hr_recruitment/hr_recruitment_view.xml index 9cbfd4560e7..e751fd5bb04 100644 --- a/addons/hr_recruitment/hr_recruitment_view.xml +++ b/addons/hr_recruitment/hr_recruitment_view.xml @@ -39,7 +39,7 @@ Applicants hr.applicant - + @@ -58,7 +58,6 @@ - @@ -69,11 +68,9 @@
-
@@ -115,7 +112,6 @@ - @@ -165,7 +161,7 @@ - + @@ -176,14 +172,11 @@ + + + - - - - - - @@ -342,7 +335,6 @@ - @@ -360,7 +352,6 @@ - diff --git a/addons/hr_recruitment/report/hr_recruitment_report.py b/addons/hr_recruitment/report/hr_recruitment_report.py index 8c365b10070..b733655e51e 100644 --- a/addons/hr_recruitment/report/hr_recruitment_report.py +++ b/addons/hr_recruitment/report/hr_recruitment_report.py @@ -18,20 +18,13 @@ # along with this program. If not, see . # ############################################################################## + from openerp import tools -from openerp.osv import fields,osv +from openerp.osv import fields, osv from .. import hr_recruitment from openerp.addons.decimal_precision import decimal_precision as dp -AVAILABLE_STATES = [ - ('draft','New'), - ('open','Open'), - ('cancel', 'Refused'), - ('done', 'Hired'), - ('pending','Pending') -] - class hr_recruitment_report(osv.osv): _name = "hr.recruitment.report" _description = "Recruitments Statistics" @@ -41,7 +34,7 @@ class hr_recruitment_report(osv.osv): _columns = { 'user_id': fields.many2one('res.users', 'User', readonly=True), 'nbr': fields.integer('# of Applications', readonly=True), - 'state': fields.selection(AVAILABLE_STATES, 'Status', size=16, readonly=True), + # TDE TODO: use MONTHS 'month':fields.selection([('01', 'January'), ('02', 'February'), \ ('03', 'March'), ('04', 'April'),\ ('05', 'May'), ('06', 'June'), \ @@ -79,7 +72,6 @@ class hr_recruitment_report(osv.osv): to_char(s.create_date, 'YYYY') as year, to_char(s.create_date, 'MM') as month, to_char(s.create_date, 'YYYY-MM-DD') as day, - s.state, s.partner_id, s.company_id, s.user_id, @@ -105,7 +97,6 @@ class hr_recruitment_report(osv.osv): s.date_open, s.create_date, s.date_closed, - s.state, s.partner_id, s.company_id, s.user_id, diff --git a/addons/hr_recruitment/report/hr_recruitment_report_view.xml b/addons/hr_recruitment/report/hr_recruitment_report_view.xml index b33b2eaa053..1845a97014e 100644 --- a/addons/hr_recruitment/report/hr_recruitment_report_view.xml +++ b/addons/hr_recruitment/report/hr_recruitment_report_view.xml @@ -14,7 +14,6 @@ - @@ -46,17 +45,15 @@ hr.recruitment.report - - - - - - - + + + + + + - diff --git a/addons/hr_recruitment/test/recruitment_process.yml b/addons/hr_recruitment/test/recruitment_process.yml index 335edc71892..0a6d5426e0d 100644 --- a/addons/hr_recruitment/test/recruitment_process.yml +++ b/addons/hr_recruitment/test/recruitment_process.yml @@ -17,33 +17,8 @@ resume_ids = self.pool.get('ir.attachment').search(cr, uid, [('datas_fname','=','resume.pdf'),('res_model','=',self._name),('res_id','=',applicant.id)]) assert applicant.name == "Application for the post of Jr.application Programmer.", "Applicant name does not match." assert applicant.stage_id.id == ref('hr_recruitment.stage_job1'), "Stage should be 'Initial qualification' and is '%s'." % (applicant.stage_id.name) - assert applicant.state == "draft", "Applicant state should be 'draft'." + assert applicant.stage_id.sequence == 1, "Applicant stage sequence should be 1." assert len(resume_ids), "Resume is not attached." -- - I refuse the applicant (hr_case_programmer) -- - !python {model: hr.applicant}: | - self.case_cancel(cr, uid, [ref("hr_case_programmer")]) -- - I check the details of the refused applicant. -- - !python {model: hr.applicant}: | - applicant = self.browse(cr, uid, ref("hr_case_programmer"), context=context) - assert applicant.stage_id.id == ref('hr_recruitment.stage_job6'), "Stage should be 'Refused' and is %s." % (applicant.stage_id.name) - assert applicant.state == 'cancel', "Applicant is not in 'cancel' state." -- - I reset and re-open the previously refused applicant. -- - !python {model: hr.applicant}: | - self.case_reset(cr, uid, [ref("hr_case_programmer")]) - self.case_open(cr, uid, [ref("hr_case_programmer")]) -- - I check the details of the re-opened applicant. -- - !python {model: hr.applicant}: | - applicant = self.browse(cr, uid, ref("hr_case_programmer"), context=context) - assert applicant.stage_id.id == ref('hr_recruitment.stage_job2'), "Stage should be 'First interview' and is '%s'." % (applicant.stage_id.name) - assert applicant.state == "open", "Applicant state should be 'open'." - I assign the Job position to the applicant - @@ -54,21 +29,6 @@ - !python {model: hr.applicant}: | self.action_makeMeeting(cr, uid, [ref('hr_case_programmer')]) -- - I check Initial Qualification of applicant. -- - !python {model: hr.applicant}: | - self.stage_next(cr, uid, [ref('hr_case_programmer')]) -- - I schedule First Interview of applicant. -- - !python {model: hr.applicant}: | - self.stage_next(cr, uid, [ref('hr_case_programmer')]) -- - On a successful First Interview of applicant, I schedule Second Interview. -- - !python {model: hr.applicant}: | - self.stage_next(cr, uid, [ref('hr_case_programmer')]) - Applicant fillup the answer of the interview quetion. - @@ -84,39 +44,19 @@ - !python {model: hr.applicant}: | self.action_print_survey(cr, uid, [ref('hr_case_programmer')]) -- - On a successful Second Interview of applicant Contract is Proposed to applicant. -- - !python {model: hr.applicant}: | - self.stage_next(cr, uid, [ref('hr_case_programmer')]) - self.stage_previous(cr, uid, [ref('hr_case_programmer')]) -- - I Hired Applicant. -- - !python {model: hr.applicant}: | - self.case_close_with_emp(cr, uid, [ref('hr_case_programmer')]) -- - I check that applicant is "Hired". -- - !assert {model: hr.applicant, id: hr_case_programmer, string: Applicant state is done}: - - state == 'done' - I do not give employment to the hired the applicant. - !python {model: hired.employee}: | context.update({'active_model': 'hr.applicant', 'active_ids': [ref("hr_recruitment.hr_case_programmer")], 'active_id': ref("hr_recruitment.hr_case_programmer")}) emp_id = self.create(cr, uid, {}, context=context) - self.case_close(cr, uid, [emp_id], context=context) - Now I give employment to hired applicant . - !python {model: hr.applicant}: | hired_emp_obj = self.pool.get('hired.employee') - self.case_reset(cr, uid, [ref("hr_case_programmer")]) - self.case_open(cr, uid, [ref("hr_case_programmer")]) context.update({'active_model': 'hr.applicant', 'active_ids': [ref("hr_recruitment.hr_case_programmer")], 'active_id': ref("hr_recruitment.hr_case_programmer")}) emp_hr_id = hired_emp_obj.create(cr, uid, {}, context=context) - hired_emp_obj.case_close_with_emp(cr, uid, [emp_hr_id], context=context) - Now hired employee want to be a partner of company. - From 2bd74561ad9979385c091a4c22b34a4b5a5cea31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 27 Jun 2013 12:09:22 +0200 Subject: [PATCH 02/12] [FIX] hr_recruitment: removed get_default_email that was in most cases unnecessary bzr revid: tde@openerp.com-20130627100922-upqi33ex4v601gng --- addons/hr_recruitment/hr_recruitment.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 4745672179b..81097820c5a 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -221,8 +221,7 @@ class hr_applicant(osv.Model): _defaults = { 'active': lambda *a: 1, - 'user_id': lambda s, cr, uid, c: uid, - 'email_from': lambda s, cr, uid, c: s._get_default_email(cr, uid, c), + 'user_id': lambda s, cr, uid, c: uid, 'stage_id': lambda s, cr, uid, c: s._get_default_stage_id(cr, uid, c), 'department_id': lambda s, cr, uid, c: s._get_default_department_id(cr, uid, c), 'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'hr.applicant', context=c), From 589826e1874d5406737f69626761c9420306cce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 27 Jun 2013 17:45:05 +0200 Subject: [PATCH 03/12] [IMP] hr_recruitment: button 'create employee' now a link next to the emp_id field. bzr revid: tde@openerp.com-20130627154505-oe8wb62brm927knr --- addons/hr_recruitment/hr_recruitment.py | 10 +++++----- addons/hr_recruitment/hr_recruitment_view.xml | 11 +++++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index e97108ad241..354221977e1 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -212,7 +212,8 @@ class hr_applicant(osv.Model): 'day_close': fields.function(_compute_day, string='Days to Close', \ multi='day_close', type="float", store=True), 'color': fields.integer('Color Index'), - 'emp_id': fields.many2one('hr.employee', 'employee'), + 'emp_id': fields.many2one('hr.employee', string='Employee', + help='Employee linked to the applicant.'), 'user_email': fields.related('user_id', 'email', type='char', string='User Email', readonly=True), } @@ -396,17 +397,16 @@ class hr_applicant(osv.Model): for applicant in self.browse(cr, uid, ids, context=context): address_id = contact_name = False if applicant.partner_id: - address_id = self.pool.get('res.partner').address_get(cr,uid,[applicant.partner_id.id],['contact'])['contact'] - contact_name = self.pool.get('res.partner').name_get(cr,uid,[applicant.partner_id.id])[0][1] + address_id = self.pool.get('res.partner').address_get(cr, uid, [applicant.partner_id.id], ['contact'])['contact'] + contact_name = self.pool.get('res.partner').name_get(cr, uid, [applicant.partner_id.id])[0][1] if applicant.job_id and (applicant.partner_name or contact_name): applicant.job_id.write({'no_of_recruitment': applicant.job_id.no_of_recruitment - 1}) - emp_id = hr_employee.create(cr,uid,{'name': applicant.partner_name or contact_name, + emp_id = hr_employee.create(cr, uid, {'name': applicant.partner_name or contact_name, 'job_id': applicant.job_id.id, 'address_home_id': address_id, 'department_id': applicant.department_id.id }) self.write(cr, uid, [applicant.id], {'emp_id': emp_id}, context=context) - self.case_close(cr, uid, [applicant.id], context) else: raise osv.except_osv(_('Warning!'), _('You must define an Applied Job and a Contact Name for this applicant.')) diff --git a/addons/hr_recruitment/hr_recruitment_view.xml b/addons/hr_recruitment/hr_recruitment_view.xml index e751fd5bb04..faf43ebdc15 100644 --- a/addons/hr_recruitment/hr_recruitment_view.xml +++ b/addons/hr_recruitment/hr_recruitment_view.xml @@ -68,11 +68,7 @@
- -
@@ -138,6 +134,13 @@ +
+
From ef9923feb41cffcc2a3f405d243b7027c0fde6b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 8 Jul 2013 10:39:21 +0200 Subject: [PATCH 04/12] [FIX] Removed get_default_email, already removed but that came back when merging trunk bzr revid: tde@openerp.com-20130708083921-a6zm0peez8is9qsg --- addons/hr_recruitment/hr_recruitment.py | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index cc5bd99acee..a140e9816d6 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -220,7 +220,6 @@ class hr_applicant(osv.Model): _defaults = { 'active': lambda *a: 1, 'user_id': lambda s, cr, uid, c: uid, - 'email_from': lambda s, cr, uid, c: s._get_default_email(cr, uid, c), 'stage_id': lambda s, cr, uid, c: s._get_default_stage_id(cr, uid, c), 'department_id': lambda s, cr, uid, c: s._get_default_department_id(cr, uid, c), 'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'hr.applicant', context=c), From 05359f0909e39404896a113de8a418e41ed9eacb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 8 Jul 2013 11:11:56 +0200 Subject: [PATCH 05/12] [IMP] hr_recruitment: added date_last_stage_update field, holding date of last stage modification; removed hired.employee wizard that does not seem to be used anywhere, nor to be useful. bzr revid: tde@openerp.com-20130708091156-3l6fcl6drd4b6w2y --- addons/hr_recruitment/__openerp__.py | 2 +- addons/hr_recruitment/hr_recruitment.py | 21 ++++++-- addons/hr_recruitment/hr_recruitment_view.xml | 15 +++--- .../report/hr_recruitment_report.py | 16 +++--- .../report/hr_recruitment_report_view.xml | 26 ++++----- .../test/recruitment_process.yml | 14 +---- addons/hr_recruitment/wizard/__init__.py | 4 +- .../wizard/hr_recruitment_employee_hired.py | 54 ------------------- .../wizard/hr_recruitment_employee_hired.xml | 30 ----------- 9 files changed, 50 insertions(+), 132 deletions(-) delete mode 100644 addons/hr_recruitment/wizard/hr_recruitment_employee_hired.py delete mode 100644 addons/hr_recruitment/wizard/hr_recruitment_employee_hired.xml diff --git a/addons/hr_recruitment/__openerp__.py b/addons/hr_recruitment/__openerp__.py index e83c546af04..b2084fb66ee 100644 --- a/addons/hr_recruitment/__openerp__.py +++ b/addons/hr_recruitment/__openerp__.py @@ -47,7 +47,7 @@ You can define the different phases of interviews and easily rate the applicant 'fetchmail', ], 'data': [ - 'wizard/hr_recruitment_employee_hired.xml', + # 'wizard/hr_recruitment_employee_hired.xml', 'wizard/hr_recruitment_create_partner_job_view.xml', 'hr_recruitment_view.xml', 'hr_recruitment_menu.xml', diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index a140e9816d6..710b796ee59 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -185,10 +185,9 @@ class hr_applicant(osv.Model): 'categ_ids': fields.many2many('hr.applicant_category', string='Tags'), 'company_id': fields.many2one('res.company', 'Company'), 'user_id': fields.many2one('res.users', 'Responsible', track_visibility='onchange'), - # Applicant Columns 'date_closed': fields.datetime('Closed', readonly=True, select=True), - 'date_open': fields.datetime('Opened', readonly=True, select=True), - 'date': fields.datetime('Date'), + 'date_open': fields.datetime('Assigned', readonly=True, select=True), + 'date_last_stage_update': fields.datetime('Last Stage Update', select=True), 'date_action': fields.date('Next Action Date'), 'title_action': fields.char('Next Action', size=64), 'priority': fields.selection(AVAILABLE_PRIORITIES, 'Appreciation'), @@ -224,6 +223,7 @@ class hr_applicant(osv.Model): 'department_id': lambda s, cr, uid, c: s._get_default_department_id(cr, uid, c), 'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'hr.applicant', context=c), 'color': 0, + 'date_last_stage_update': fields.datetime.now(), } _group_by_full = { @@ -390,7 +390,20 @@ class hr_applicant(osv.Model): self.pool.get('hr.job').message_post(cr, uid, [applicant.job_id.id], body=_('Applicant created'), subtype="hr_recruitment.mt_job_new_applicant", context=context) return obj_id - def case_close_with_emp(self, cr, uid, ids, context=None): + def write(self, cr, uid, ids, vals, context=None): + if isinstance(ids, (int, long)): + ids = [ids] + # stage change: update date_last_stage_update + if 'stage_id' in vals: + vals['date_last_stage_update'] = fields.datetime.now() + # user_id change: update date_start + if vals.get('user_id'): + vals['date_start'] = fields.datetime.now() + + return super(hr_applicant, self).write(cr, uid, ids, vals, context=context) + + def create_employee_from_applicant(self, cr, uid, ids, context=None): + """ Create an hr.employee from the hr.applicants """ if context is None: context = {} hr_employee = self.pool.get('hr.employee') diff --git a/addons/hr_recruitment/hr_recruitment_view.xml b/addons/hr_recruitment/hr_recruitment_view.xml index 8134e0f625d..ae7601416a2 100644 --- a/addons/hr_recruitment/hr_recruitment_view.xml +++ b/addons/hr_recruitment/hr_recruitment_view.xml @@ -86,9 +86,12 @@