From: Ysa (Open ERP) Date: Wed, 7 Apr 2010 14:40:28 +0000 (+0530) Subject: [IMP] hr_recruitment :- improvement, add next and previous stage button, scheduled... X-Git-Tag: 6.0.0-rc1-addons~69^2~497 X-Git-Url: http://git.inspyration.org/?a=commitdiff_plain;h=aa9afc11470f15885b9df69d0afdf5c481d9608a;p=odoo%2Fodoo.git [IMP] hr_recruitment :- improvement, add next and previous stage button, scheduled meeting button not work and other small changes. bzr revid: ysa@tinyerp.co.in-20100407144028-vaya1ffdlqaqcdfj --- diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 26ac6a1..034a99a 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -20,6 +20,7 @@ ############################################################################## from osv import fields,osv,orm +from tools.translate import _ AVAILABLE_STATES = [ ('draft','New'), @@ -54,14 +55,101 @@ class hr_applicant(osv.osv): 'partner_name': fields.char("Applicant's Name", size=64), 'partner_phone': fields.char('Phone', size=32), 'partner_mobile': fields.char('Mobile', size=32), - 'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'hr.applicant')]"), - 'type_id': fields.many2one('crm.case.resource.type', 'Degree', domain="[('section_id','=',section_id),('object_id.model', '=', 'hr.applicant')]"), + 'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('object_id.model', '=', 'hr.applicant')]"), + 'type_id': fields.many2one('crm.case.resource.type', 'Degree', domain="[('object_id.model', '=', 'hr.applicant')]"), 'department_id':fields.many2one('hr.department','Department'), 'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True), 'survey' : fields.related('job_id', 'survey_id', type='many2one', relation='survey', string='Survey'), 'response' : fields.integer("Response"), } - + + def stage_previous(self, cr, uid, ids, context=None): + """This function computes previous stage for case from its current stage + using available stage for that case type + @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 case IDs + @param context: A standard dictionary for contextual values""" + if not context: + context = {} + for case in self.browse(cr, uid, ids, context): + section = (case.section_id.id or False) + st = case.stage_id.id or False + stage_ids = self.pool.get('crm.case.stage').search(cr, uid, []) + if st and stage_ids.index(st): + self.write(cr, uid, [case.id], {'stage_id': stage_ids[stage_ids.index(st)-1]}) + return True + + def stage_next(self, cr, uid, ids, context=None): + """This function computes next stage for case from its current stage + using available stage for that case type + @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 case IDs + @param context: A standard dictionary for contextual values""" + if not context: + context = {} + for case in self.browse(cr, uid, ids, context): + section = (case.section_id.id or False) + st = case.stage_id.id or False + stage_ids = self.pool.get('crm.case.stage').search(cr, uid, []) + if st and len(stage_ids) != stage_ids.index(st)+1: + self.write(cr, uid, [case.id], {'stage_id': stage_ids[stage_ids.index(st)+1]}) + return True + + def action_makeMeeting(self, cr, uid, ids, context=None): + """ + 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 + """ + value = {} + for opp in self.browse(cr, uid, ids): + data_obj = self.pool.get('ir.model.data') + + # Get meeting views + result = data_obj._get_id(cr, uid, 'crm', 'view_crm_case_meetings_filter') + res = data_obj.read(cr, uid, result, ['res_id']) + id1 = data_obj._get_id(cr, uid, 'crm', 'crm_case_calendar_view_meet') + id2 = data_obj._get_id(cr, uid, 'crm', 'crm_case_form_view_meet') + id3 = data_obj._get_id(cr, uid, 'crm', 'crm_case_tree_view_meet') + if id1: + id1 = data_obj.browse(cr, uid, id1, context=context).res_id + if id2: + id2 = data_obj.browse(cr, uid, id2, context=context).res_id + if id3: + id3 = data_obj.browse(cr, uid, id3, context=context).res_id + + context = { + 'default_opportunity_id': opp.id, + 'default_partner_id': opp.partner_id and opp.partner_id.id or False, + 'default_section_id': opp.section_id and opp.section_id.id or False, + 'default_email_from': opp.email_from, + 'default_state': 'open', + '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': [(id1, 'calendar'), (id2, 'form'), (id3, 'tree')], + 'type': 'ir.actions.act_window', + 'search_view_id': res['res_id'], + 'nodestroy': True + } + return value + def action_print_survey(self, cr, uid, ids, context=None): """ If response is available then print this response otherwise print survey form(print template of the survey). diff --git a/addons/hr_recruitment/hr_recruitment_view.xml b/addons/hr_recruitment/hr_recruitment_view.xml index 2cabc56..1c0f332 100644 --- a/addons/hr_recruitment/hr_recruitment_view.xml +++ b/addons/hr_recruitment/hr_recruitment_view.xml @@ -43,8 +43,8 @@ -