X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=addons%2Fhr_recruitment%2Fhr_recruitment.py;h=25416bd3920e79f3b6931cc6b63cb8936eacc9f0;hb=5b2c56e935615299b7255f1193e86616607eff20;hp=32bebef3dc0c17ed22a45342aea557898c788ddb;hpb=c407fa45ce7171ca47e11854eb6a45460f1c3dfd;p=odoo%2Fodoo.git diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 32bebef..25416bd 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -62,8 +62,8 @@ class hr_recruitment_stage(osv.osv): _columns = { '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 tempy this field."), - 'state': fields.selection(AVAILABLE_STATES, 'State', required=True, help="The related state for the stage. The state of your document will automatically change regarding the selected stage. Example, a stage is related to the state 'Close', when your document reach this stage, it will be automatically closed."), + '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, 'State', required=True, help="The related state for the stage. The state of your document will automatically change according to the selected stage. Example, a stage is related to the state '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'), } @@ -177,7 +177,7 @@ class hr_applicant(base_stage, osv.Model): return res _columns = { - 'name': fields.char('Name', size=128, required=True), + 'name': fields.char('Subject', size=128, required=True), 'active': fields.boolean('Active', help="If the active field is set to false, it will allow you to hide the case without removing it."), 'description': fields.text('Description'), 'email_from': fields.char('Email', size=128, help="These people will receive email."), @@ -209,7 +209,7 @@ class hr_applicant(base_stage, osv.Model): 'salary_expected_extra': fields.char('Expected Salary Extra', size=100, help="Salary Expected by Applicant, extra advantages"), 'salary_proposed': fields.float('Proposed Salary', help="Salary Proposed by the Organisation"), 'salary_expected': fields.float('Expected Salary', help="Salary Expected by Applicant"), - 'availability': fields.integer('Availability (Days)'), + 'availability': fields.integer('Availability'), 'partner_name': fields.char("Applicant's Name", size=64), 'partner_phone': fields.char('Phone', size=32), 'partner_mobile': fields.char('Mobile', size=32), @@ -242,6 +242,25 @@ class hr_applicant(base_stage, osv.Model): _group_by_full = { 'stage_id': _read_group_stage_ids } + + def onchange_stage_id(self, cr, uid, ids, stage_id, context={}): + if context is None: + context = {} + if not stage_id: + return {'value':{}} + stage = self.pool.get('hr.recruitment.stage').browse(cr, uid, stage_id, context) + if stage.state == "draft": + return {'value':{'active': True,'date_open': False, 'date_closed': False}} + if stage.state == "open": + cases = self.browse(cr, uid, ids, context=context) + data = {'active': True} + for case in cases: + if case.stage_id and case.stage_id.state == 'draft': + data['date_open'] = fields.datetime.now() + if not case.user_id: + data['user_id'] = uid + return {'value':data} + return {'value':{}} def onchange_job(self,cr, uid, ids, job, context=None): result = {} @@ -253,8 +272,6 @@ class hr_applicant(base_stage, osv.Model): return {'value': {'department_id': False}} def onchange_department_id(self, cr, uid, ids, department_id=False, context=None): - if not department_id: - return {'value': {'stage_id': False}} obj_recru_stage = self.pool.get('hr.recruitment.stage') stage_ids = obj_recru_stage.search(cr, uid, ['|',('department_id','=',department_id),('department_id','=',False)], context=context) stage_id = stage_ids and stage_ids[0] or False @@ -289,49 +306,20 @@ class hr_applicant(base_stage, osv.Model): return False def action_makeMeeting(self, cr, uid, ids, context=None): + """ This opens Meeting's calendar view to schedule meeting on current applicant + @return: Dictionary value for created Meeting view """ - This opens Meeting's calendar view to schedule meeting on current Opportunity - @param self: The object pointer - @param cr: the current row, from the database cursor, - @param uid: the current user’s ID for security checks, - @param ids: List of Opportunity to Meeting IDs - @param context: A standard dictionary for contextual values - - @return: Dictionary value for created Meeting view - """ - data_obj = self.pool.get('ir.model.data') - if context is None: - context = {} - value = {} - for opp in self.browse(cr, uid, ids, context=context): - # Get meeting views - search_view = data_obj.get_object(cr, uid, 'crm', 'view_crm_case_meetings_filter', context) - calendar_view = data_obj.get_object(cr, uid, 'crm', 'crm_case_calendar_view_meet', context) - form_view = data_obj.get_object(cr, uid, 'crm', 'crm_case_form_view_meet', context) - tree_view = data_obj.get_object(cr, uid, 'crm', 'crm_case_tree_view_meet', context) - category = data_obj.get_object(cr, uid, 'hr_recruitment', 'categ_meet_interview', context) - context.update({ - 'default_applicant_id': opp.id, - 'default_partner_id': opp.partner_id and opp.partner_id.id or False, - 'default_email_from': opp.email_from, - 'default_state': 'open', - 'default_categ_id': category.id, - 'default_name': opp.name, - }) - value = { - 'name': ('Meetings'), - 'domain': "[('user_id','=',%s)]" % (uid), - 'context': context, - 'view_type': 'form', - 'view_mode': 'calendar,form,tree', - 'res_model': 'crm.meeting', - 'view_id': False, - 'views': [(calendar_view.id, 'calendar'), (form_view.id, 'form'), (tree_view.id, 'tree')], - 'type': 'ir.actions.act_window', - 'search_view_id': search_view.id, - 'nodestroy': True, - } - return value + applicant = self.browse(cr, uid, ids[0], context) + category = self.pool.get('ir.model.data').get_object(cr, uid, 'hr_recruitment', 'categ_meet_interview', context) + res = self.pool.get('ir.actions.act_window').for_xml_id(cr, uid, 'base_calendar', 'action_crm_meeting', context) + res['context'] = { + 'default_partner_ids': applicant.partner_id and [applicant.partner_id.id] or False, + 'default_user_id': uid, + 'default_state': 'open', + 'default_name': applicant.name, + 'default_categ_ids': category and [category.id] or False, + } + return res def action_print_survey(self, cr, uid, ids, context=None): """ @@ -438,8 +426,11 @@ class hr_applicant(base_stage, osv.Model): '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) + if context.get('onchange'): + return {'value':{'emp_id': emp_id,'active': True, 'date_closed': fields.datetime.now()}} + else: + 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 Applied Job for this applicant.')) @@ -469,6 +460,16 @@ class hr_applicant(base_stage, osv.Model): 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 stage_set(self, cr, uid, ids, stage_id, context=None): + if context is None: + context = {} + res = super(hr_applicant, self).stage_set(cr, uid, ids,stage_id, context) + stage = self.pool.get('hr.recruitment.stage').browse(cr, uid, stage_id, context) + if stage.state == 'done': + context['onchange'] = True + self.case_close_with_emp(cr, uid, ids, context) + return res def set_priority(self, cr, uid, ids, priority, *args): """Set applicant priority @@ -559,11 +560,4 @@ class hr_job(osv.osv): 'nodestroy':True, } - -class crm_meeting(osv.osv): - _inherit = 'crm.meeting' - _columns = { - 'applicant_id': fields.many2one('hr.applicant','Applicant'), - } - # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: