From 278ab8a96a2340a3b05e11995f04623730564a03 Mon Sep 17 00:00:00 2001 From: "Hardik Ansodariy (OpenERP)" Date: Tue, 3 Jan 2012 16:44:58 +0530 Subject: [PATCH 1/4] [IMP] if interview appraisal has wait for previous phase = True then can not be answered until previous phase done bzr revid: han@tinyerp.com-20120103111458-lk92c5n32okkkagz --- addons/hr_evaluation/hr_evaluation.py | 6 ++++++ addons/survey/wizard/survey_answer.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/addons/hr_evaluation/hr_evaluation.py b/addons/hr_evaluation/hr_evaluation.py index 58ad9d9b3e0..ccc9a01ab32 100644 --- a/addons/hr_evaluation/hr_evaluation.py +++ b/addons/hr_evaluation/hr_evaluation.py @@ -224,6 +224,8 @@ class hr_evaluation(osv.osv): wait = True if not wait: hr_eval_inter_obj.survey_req_waiting_answer(cr, uid, [int_id], context=context) + elif wait: + hr_eval_inter_obj.survey_req_draft_answer(cr, uid, [int_id], context=context) if (not wait) and phase.mail_feature: body = phase.mail_body % {'employee_name': child.name, 'user_signature': child.user_id.signature, @@ -309,6 +311,10 @@ class hr_evaluation_interview(osv.osv): def survey_req_waiting_answer(self, cr, uid, ids, context=None): self.write(cr, uid, ids, { 'state': 'waiting_answer'}, context=context) return True + + def survey_req_draft_answer(self, cr, uid, ids, context=None): + self.write(cr, uid, ids, { 'state': 'draft'}, context=context) + return True def survey_req_done(self, cr, uid, ids, context=None): hr_eval_obj = self.pool.get('hr_evaluation.evaluation') diff --git a/addons/survey/wizard/survey_answer.py b/addons/survey/wizard/survey_answer.py index a4b67896e89..93ef932995b 100644 --- a/addons/survey/wizard/survey_answer.py +++ b/addons/survey/wizard/survey_answer.py @@ -56,6 +56,7 @@ class survey_question_wiz(osv.osv_memory): que_col_head = self.pool.get('survey.question.column.heading') user_obj = self.pool.get('res.users') mail_message = self.pool.get('mail.message') + obj_module = self.pool.get('ir.module.module') if view_type in ['form']: wiz_id = 0 @@ -394,6 +395,11 @@ class survey_question_wiz(osv.osv_memory): survey_data = survey_obj.browse(cr, uid, survey_id) response_id = surv_name_wiz.read(cr, uid, context.get('sur_name_id',False))['response'] context.update({'response_id':response_id}) + module_id = obj_module.search(cr, uid, [('name', '=', 'hr_evaluation')]) + state = obj_module.browse(cr, uid, module_id, context=context)[0].state + if state == 'installed': + interview_id = context.get('active_ids',False) + eval_inter_obj = self.pool.get('hr.evaluation.interview').survey_req_done(cr, uid, interview_id, context=context) report = self.create_report(cr, uid, [survey_id], 'report.survey.browse.response', survey_data.title,context) attachments = {} file = open(addons.get_module_resource('survey', 'report') + survey_data.title + ".pdf") From 7f49d4d173c301dd6f899ffddea825437b9bfa4d Mon Sep 17 00:00:00 2001 From: "Hardik Ansodariy (OpenERP)" Date: Fri, 6 Jan 2012 15:50:34 +0530 Subject: [PATCH 2/4] [IMP] removed survey_req_draft method and used active_model to determin survey request bzr revid: han@tinyerp.com-20120106102034-qnyfyil9kiop2k1c --- addons/hr_evaluation/hr_evaluation.py | 8 +------- addons/survey/wizard/survey_answer.py | 9 +++------ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/addons/hr_evaluation/hr_evaluation.py b/addons/hr_evaluation/hr_evaluation.py index ccc9a01ab32..132a1414e63 100644 --- a/addons/hr_evaluation/hr_evaluation.py +++ b/addons/hr_evaluation/hr_evaluation.py @@ -224,8 +224,6 @@ class hr_evaluation(osv.osv): wait = True if not wait: hr_eval_inter_obj.survey_req_waiting_answer(cr, uid, [int_id], context=context) - elif wait: - hr_eval_inter_obj.survey_req_draft_answer(cr, uid, [int_id], context=context) if (not wait) and phase.mail_feature: body = phase.mail_body % {'employee_name': child.name, 'user_signature': child.user_id.signature, @@ -279,7 +277,7 @@ class survey_request(osv.osv): 'is_evaluation': fields.boolean('Is Appraisal?'), } _defaults = { - 'state': 'waiting_answer', + 'state': 'draft', } survey_request() @@ -311,10 +309,6 @@ class hr_evaluation_interview(osv.osv): def survey_req_waiting_answer(self, cr, uid, ids, context=None): self.write(cr, uid, ids, { 'state': 'waiting_answer'}, context=context) return True - - def survey_req_draft_answer(self, cr, uid, ids, context=None): - self.write(cr, uid, ids, { 'state': 'draft'}, context=context) - return True def survey_req_done(self, cr, uid, ids, context=None): hr_eval_obj = self.pool.get('hr_evaluation.evaluation') diff --git a/addons/survey/wizard/survey_answer.py b/addons/survey/wizard/survey_answer.py index 93ef932995b..c4aa7d169da 100644 --- a/addons/survey/wizard/survey_answer.py +++ b/addons/survey/wizard/survey_answer.py @@ -56,7 +56,6 @@ class survey_question_wiz(osv.osv_memory): que_col_head = self.pool.get('survey.question.column.heading') user_obj = self.pool.get('res.users') mail_message = self.pool.get('mail.message') - obj_module = self.pool.get('ir.module.module') if view_type in ['form']: wiz_id = 0 @@ -395,11 +394,9 @@ class survey_question_wiz(osv.osv_memory): survey_data = survey_obj.browse(cr, uid, survey_id) response_id = surv_name_wiz.read(cr, uid, context.get('sur_name_id',False))['response'] context.update({'response_id':response_id}) - module_id = obj_module.search(cr, uid, [('name', '=', 'hr_evaluation')]) - state = obj_module.browse(cr, uid, module_id, context=context)[0].state - if state == 'installed': - interview_id = context.get('active_ids',False) - eval_inter_obj = self.pool.get('hr.evaluation.interview').survey_req_done(cr, uid, interview_id, context=context) + survey_req_obj = self.pool.get(context.get('active_model')) + if survey_req_obj and hasattr(survey_req_obj, 'survey_req_done'): + survey_req_obj.survey_req_done(cr, uid, context.get('active_ids', []), context=context) report = self.create_report(cr, uid, [survey_id], 'report.survey.browse.response', survey_data.title,context) attachments = {} file = open(addons.get_module_resource('survey', 'report') + survey_data.title + ".pdf") From 0592614e9007b1b986e987db3ad5a1f4971cde68 Mon Sep 17 00:00:00 2001 From: "Hardik Ansodariy (OpenERP)" Date: Fri, 6 Jan 2012 18:16:52 +0530 Subject: [PATCH 3/4] [IMP] removed default state from inherited survey.request bzr revid: han@tinyerp.com-20120106124652-bhy30iuz84ks5zcy --- addons/hr_evaluation/hr_evaluation.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/addons/hr_evaluation/hr_evaluation.py b/addons/hr_evaluation/hr_evaluation.py index 132a1414e63..6e1983d7a11 100644 --- a/addons/hr_evaluation/hr_evaluation.py +++ b/addons/hr_evaluation/hr_evaluation.py @@ -276,9 +276,6 @@ class survey_request(osv.osv): _columns = { 'is_evaluation': fields.boolean('Is Appraisal?'), } - _defaults = { - 'state': 'draft', - } survey_request() From fd5d00946f2ce10fe547a2d9fdd466287ced1c2f Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Mon, 9 Jan 2012 14:57:47 +0100 Subject: [PATCH 4/4] [IMP] survey: move code bzr revid: rco@openerp.com-20120109135747-yc7gw2qy8ho23xht --- addons/survey/wizard/survey_answer.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/survey/wizard/survey_answer.py b/addons/survey/wizard/survey_answer.py index c4aa7d169da..8826051e922 100644 --- a/addons/survey/wizard/survey_answer.py +++ b/addons/survey/wizard/survey_answer.py @@ -390,13 +390,15 @@ class survey_question_wiz(osv.osv_memory): survey_obj.write(cr, uid, survey_id, {'tot_comp_survey' : sur_rec.tot_comp_survey + 1}) sur_response_obj.write(cr, uid, [sur_name_read.response], {'state' : 'done'}) + # mark the survey request as done; call 'survey_req_done' on its actual model + survey_req_obj = self.pool.get(context.get('active_model')) + if survey_req_obj and hasattr(survey_req_obj, 'survey_req_done'): + survey_req_obj.survey_req_done(cr, uid, context.get('active_ids', []), context=context) + if sur_rec.send_response: survey_data = survey_obj.browse(cr, uid, survey_id) response_id = surv_name_wiz.read(cr, uid, context.get('sur_name_id',False))['response'] context.update({'response_id':response_id}) - survey_req_obj = self.pool.get(context.get('active_model')) - if survey_req_obj and hasattr(survey_req_obj, 'survey_req_done'): - survey_req_obj.survey_req_done(cr, uid, context.get('active_ids', []), context=context) report = self.create_report(cr, uid, [survey_id], 'report.survey.browse.response', survey_data.title,context) attachments = {} file = open(addons.get_module_resource('survey', 'report') + survey_data.title + ".pdf")