diff --git a/addons/hr_recruitment/__openerp__.py b/addons/hr_recruitment/__openerp__.py index cb1dd54e902..8127d85d527 100644 --- a/addons/hr_recruitment/__openerp__.py +++ b/addons/hr_recruitment/__openerp__.py @@ -37,7 +37,8 @@ You can define the different phases of interviews and easily rate the applicant """, 'author': 'OpenERP SA', 'website': 'http://www.openerp.com', - 'images': ['images/hr_recruitment_analysis.jpeg','images/hr_recruitment_applicants.jpeg'], + 'images': ['images/hr_recruitment_analysis.jpeg', + 'images/hr_recruitment_applicants.jpeg'], 'depends': [ 'decimal_precision', 'hr', @@ -55,6 +56,7 @@ You can define the different phases of interviews and easily rate the applicant 'board_hr_recruitment_statistical_view.xml', 'hr_recruitment_installer_view.xml', 'res_config_view.xml', + 'survey_data_recruitment.xml', 'hr_recruitment_data.xml', ], 'demo': ['hr_recruitment_demo.xml'], diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 89dd592e032..087f86748cd 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -213,8 +213,8 @@ class hr_applicant(osv.Model): 'partner_mobile': fields.char('Mobile', size=32), 'type_id': fields.many2one('hr.recruitment.degree', 'Degree'), 'department_id': fields.many2one('hr.department', 'Department'), - 'survey': fields.related('job_id', 'survey_id', type='many2one', relation='survey', string='Survey'), - 'response': fields.integer("Response"), + 'survey': fields.related('job_id', 'survey_id', type='many2one', relation='survey.survey', string='Survey'), + 'response_id': fields.many2one('survey.user_input', "Response", ondelete='set null', oldname="response"), 'reference': fields.char('Referred By', size=128), 'source_id': fields.many2one('hr.recruitment.source', 'Source'), 'day_open': fields.function(_compute_day, string='Days to Open', \ @@ -312,24 +312,34 @@ class hr_applicant(osv.Model): } return res - 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). + def action_start_survey(self, cr, uid, ids, context=None): + context = context if context else {} + applicant = self.browse(cr, uid, ids, context=context)[0] + survey_obj = self.pool.get('survey.survey') + response_obj = self.pool.get('survey.user_input') + # create a response and link it to this applicant + if not applicant.response_id: + response_id = response_obj.create(cr, uid, {'survey_id': applicant.survey.id, 'partner_id': applicant.partner_id.id}, context=context) + self.write(cr, uid, ids[0], {'response_id': response_id}, context=context) + else: + response_id = applicant.response_id.id + # grab the token of the response and start surveying + response = response_obj.browse(cr, uid, response_id, context=context) + context.update({'survey_token': response.token}) + return survey_obj.action_start_survey(cr, uid, [applicant.survey.id], context=context) - @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 Survey IDs - @param context: A standard dictionary for contextual values - @return: Dictionary value for print survey form. - """ - if context is None: - context = {} - record = self.browse(cr, uid, ids, context=context) - record = record and record[0] - context.update({'survey_id': record.survey.id, 'response_id': [record.response], 'response_no': 0, }) - value = self.pool.get("survey").action_print_survey(cr, uid, ids, context=context) - 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) """ + context = context if context else {} + applicant = self.browse(cr, uid, ids, context=context)[0] + survey_obj = self.pool.get('survey.survey') + response_obj = self.pool.get('survey.user_input') + if not applicant.response_id: + return survey_obj.action_print_survey(cr, uid, [applicant.survey.id], context=context) + else: + response = response_obj.browse(cr, uid, applicant.response_id.id, context=context) + context.update({'survey_token': response.token}) + return survey_obj.action_print_survey(cr, uid, [applicant.survey.id], context=context) def action_get_attachment_tree_view(self, cr, uid, ids, context): domain = ['&', ('res_model', '=', 'hr.applicant'), ('res_id', 'in', ids)] @@ -491,7 +501,7 @@ class hr_job(osv.osv): _name = "hr.job" _inherits = {'mail.alias': 'alias_id'} _columns = { - 'survey_id': fields.many2one('survey', 'Interview Form', help="Choose an interview form for this job position and you will be able to print/answer this interview from all applicants who apply for this job"), + 'survey_id': fields.many2one('survey.survey', 'Interview Form', help="Choose an interview form for this job position and you will be able to print/answer this interview from all applicants who apply for this job"), 'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="restrict", required=True, help="Email alias for this job position. New emails will automatically " "create new applicants for this job position."), @@ -525,21 +535,9 @@ class hr_job(osv.osv): return res def action_print_survey(self, cr, uid, ids, context=None): - if context is None: - context = {} - datas = {} - record = self.browse(cr, uid, ids, context=context)[0] - if record.survey_id: - datas['ids'] = [record.survey_id.id] - datas['model'] = 'survey.print' - context.update({'response_id': [0], 'response_no': 0}) - return { - 'type': 'ir.actions.report.xml', - 'report_name': 'survey.form', - 'datas': datas, - 'context': context, - 'nodestroy': True, - } + job = self.browse(cr, uid, ids, context=context)[0] + survey_id = job.survey_id.id + return self.pool.get('survey.survey').action_print_survey(cr, uid, [survey_id], context=context) class applicant_category(osv.osv): diff --git a/addons/hr_recruitment/hr_recruitment_data.xml b/addons/hr_recruitment/hr_recruitment_data.xml index 76f3d3b72be..a218e5fb5d0 100644 --- a/addons/hr_recruitment/hr_recruitment_data.xml +++ b/addons/hr_recruitment/hr_recruitment_data.xml @@ -118,379 +118,6 @@ - - Job Survey - 20 - - - - 5 - - - Default Section - - - - - Education & Activities - - - - - Importance - - - - - 1 - do_not_validate - do_not_validate - Please enter a comment. - The choices need to add up to [enter sum here]. - - The comment you entered is in an invalid format. - - This question requires an answer. - - From which university will you graduate? - - single_textbox - The comment you entered is in an invalid format. - - - - Other - - - - - 1 - do_not_validate - do_not_validate - Please enter a comment. - The choices need to add up to [enter sum here]. - - The comment you entered is in an invalid format. - - This question requires an answer. - - Rate the Importance - - matrix_of_choices_only_one_ans - The comment you entered is in an invalid format. - - - - Other - - - - - 1 - do_not_validate - do_not_validate - Please enter a comment. - The choices need to add up to [enter sum here]. - - The comment you entered is in an invalid format. - - This question requires an answer. - - Education - - comment - The comment you entered is in an invalid format. - - - - Other - - - - - 1 - do_not_validate - do_not_validate - Please enter a comment. - The choices need to add up to [enter sum here]. - - The comment you entered is in an invalid format. - - This question requires an answer. - - Knowledge - - comment - The comment you entered is in an invalid format. - - - - Other - - - - - 1 - do_not_validate - do_not_validate - Please enter a comment. - The choices need to add up to [enter sum here]. - - The comment you entered is in an invalid format. - - This question requires an answer. - - What is your gender? - - multiple_choice_only_one_ans - The comment you entered is in an invalid format. - - - - Other - - - - - - 1 - Male - - - - - - 1 - Female - - - - - - 1 - do_not_validate - do_not_validate - Please enter a comment. - The choices need to add up to [enter sum here]. - - The comment you entered is in an invalid format. - - This question requires an answer. - - What age group do you belong to? - - multiple_choice_only_one_ans - The comment you entered is in an invalid format. - - - - Other - - - - - - 1 - 0 - 15 - - - - - 1 - 16 - 20 - - - - - 1 - 21 - 30 - - - - - 1 - 31 - 40 - - - - - 1 - 41 - 50 - - - - - 1 - 51 - 60 - - - - - 1 - 61 - 70 - - - - - 1 - 71 + - - - - - - 1 - do_not_validate - do_not_validate - Please enter a comment. - The choices need to add up to [enter sum here]. - - The comment you entered is in an invalid format. - - This question requires an answer. - - Experience - - comment - The comment you entered is in an invalid format. - - - - Other - - - - - 1 - do_not_validate - do_not_validate - Please enter a comment. - The choices need to add up to [enter sum here]. - - The comment you entered is in an invalid format. - - This question requires an answer. - - Activities - - comment - The comment you entered is in an invalid format. - - - - Other - - - - - - Not important - - - - - - Somewhat important - - - - - - Important - - - - - - Very important - - - - - - Most important - - - - - 1 - Good pay - - - - - 1 - Getting on with colleagues - - - - - 1 - Office environment (décor, light, space etc) - - - - - 1 - Desk space - - - - - 1 - State of the art technology - - - - - 1 - Office location (proximity to home) - - - - - 1 - Good management/boss - - - - - 1 - Freebies such as tea, coffee and stationery - - - - - 1 - Perks such as free parking, gym passes etc - - - - - 1 - No out of hours working - - - - - 1 - Dress code - - - - - 1 - Regular meetings - - - - - 1 - Good social life (office nights out, good Christmas parties etc) - - - - jobs diff --git a/addons/hr_recruitment/hr_recruitment_demo.xml b/addons/hr_recruitment/hr_recruitment_demo.xml index 8ba49a2beb8..3d6c05c1489 100644 --- a/addons/hr_recruitment/hr_recruitment_demo.xml +++ b/addons/hr_recruitment/hr_recruitment_demo.xml @@ -126,35 +126,35 @@ recruit 4 - + - + - + recruit 1 - + 1 recruit - + recruit 3 - + recruit 6 - + - + --> hr.applicant diff --git a/addons/hr_recruitment/hr_recruitment_view.xml b/addons/hr_recruitment/hr_recruitment_view.xml index eb823364e96..e85a57dee15 100644 --- a/addons/hr_recruitment/hr_recruitment_view.xml +++ b/addons/hr_recruitment/hr_recruitment_view.xml @@ -54,7 +54,7 @@ - + @@ -76,9 +76,9 @@
@@ -106,7 +106,7 @@ -