Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MERGE] survey: clean and rename models, refactor survey results page code #41198

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion addons/hr_recruitment_survey/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
'security/hr_recruitment_survey_security.xml',
'views/hr_job_views.xml',
'views/hr_applicant_views.xml',
'views/survey_survey_views.xml',
'views/res_config_setting_views.xml',
],
'demo': [
Expand Down
55 changes: 27 additions & 28 deletions addons/hr_recruitment_survey/data/survey_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
<field name="title">Recruitment Form</field>
<field name="state">open</field>
<field name="access_mode">token</field>
<field name="category">hr_recruitment</field>
<field name="users_can_go_back" eval="True"/>
<field name="description" type="html">
<p>
Please answer those questions to help recruitment officers to preprocess your application.
</p></field>
<field name="thank_you_message" type="html">
<field name="description_done" type="html">
<p>
Thank you for answering this survey. We will come back to you soon.
</p></field>
Expand All @@ -29,19 +28,19 @@
<field name="survey_id" ref="survey_recruitment_form"/>
<field name="sequence">2</field>
<field name="title">Which country are you from ?</field>
<field name="question_type">textbox</field>
<field name="question_type">char_box</field>
</record>
<record id="survey_recruitment_form_p1_q2" model="survey.question">
<field name="survey_id" ref="survey_recruitment_form"/>
<field name="sequence">3</field>
<field name="title">From which university did or will you graduate ?</field>
<field name="question_type">textbox</field>
<field name="question_type">char_box</field>
</record>
<record id="survey_recruitment_form_p1_q3" model="survey.question">
<field name="survey_id" ref="survey_recruitment_form"/>
<field name="sequence">4</field>
<field name="title">Did you apply from an employee ?</field>
<field name="question_type">textbox</field>
<field name="question_type">char_box</field>
</record>

<record id="survey_recruitment_form_p1_q4" model="survey.question">
Expand All @@ -50,31 +49,31 @@
<field name="title">Education</field>
<field name="description" type="html">
<p>Please summarize your education history: schools, location, diplomas, ...</p></field>
<field name="question_type">free_text</field>
<field name="question_type">text_box</field>
</record>
<record id="survey_recruitment_form_p1_q5" model="survey.question">
<field name="survey_id" ref="survey_recruitment_form"/>
<field name="sequence">5</field>
<field name="title">Past work experiences</field>
<field name="description" type="html">
<p>Please summarize your education history: schools, location, diplomas, ...</p></field>
<field name="question_type">free_text</field>
<field name="question_type">text_box</field>
</record>
<record id="survey_recruitment_form_p1_q6" model="survey.question">
<field name="survey_id" ref="survey_recruitment_form"/>
<field name="sequence">6</field>
<field name="title">Knowledge</field>
<field name="description" type="html">
<p>What are your main knowledge regarding the job you are applying to ?</p></field>
<field name="question_type">free_text</field>
<field name="question_type">text_box</field>
</record>
<record id="survey_recruitment_form_p1_q7" model="survey.question">
<field name="survey_id" ref="survey_recruitment_form"/>
<field name="sequence">7</field>
<field name="title">Activities</field>
<field name="description" type="html">
<p>Please tell us a bit more about yourself: what are your main activities, ...</p></field>
<field name="question_type">free_text</field>
<field name="question_type">text_box</field>
</record>

<record id="survey_recruitment_form_p1_q8" model="survey.question">
Expand All @@ -84,58 +83,58 @@
<field name="question_type">matrix</field>
<field name="matrix_subtype">simple</field>
</record>
<record id="survey_recruitment_form_p1_q8_col1" model="survey.label">
<record id="survey_recruitment_form_p1_q8_col1" model="survey.question.answer">
<field name="question_id" ref="survey_recruitment_form_p1_q8"/>
<field name="sequence">1</field>
<field name="value">Not important</field>
</record>
<record id="survey_recruitment_form_p1_q8_col2" model="survey.label">
<record id="survey_recruitment_form_p1_q8_col2" model="survey.question.answer">
<field name="question_id" ref="survey_recruitment_form_p1_q8"/>
<field name="sequence">3</field>
<field name="value">Important</field>
</record>
<record id="survey_recruitment_form_p1_q8_col3" model="survey.label">
<record id="survey_recruitment_form_p1_q8_col3" model="survey.question.answer">
<field name="question_id" ref="survey_recruitment_form_p1_q8"/>
<field name="sequence">4</field>
<field name="value">Very important</field>
</record>
<record id="survey_recruitment_form_p1_q8_row1" model="survey.label">
<field name="question_id_2" ref="survey_recruitment_form_p1_q8"/>
<record id="survey_recruitment_form_p1_q8_row1" model="survey.question.answer">
<field name="matrix_question_id" ref="survey_recruitment_form_p1_q8"/>
<field name="sequence">1</field>
<field name="value">Having a good pay</field>
</record>
<record id="survey_recruitment_form_p1_q8_row2" model="survey.label">
<field name="question_id_2" ref="survey_recruitment_form_p1_q8"/>
<record id="survey_recruitment_form_p1_q8_row2" model="survey.question.answer">
<field name="matrix_question_id" ref="survey_recruitment_form_p1_q8"/>
<field name="sequence">2</field>
<field name="value">Getting on with colleagues</field>
</record>
<record id="survey_recruitment_form_p1_q8_row3" model="survey.label">
<field name="question_id_2" ref="survey_recruitment_form_p1_q8"/>
<record id="survey_recruitment_form_p1_q8_row3" model="survey.question.answer">
<field name="matrix_question_id" ref="survey_recruitment_form_p1_q8"/>
<field name="sequence">3</field>
<field name="value">Having a nice office environment</field>
</record>
<record id="survey_recruitment_form_p1_q8_row4" model="survey.label">
<field name="question_id_2" ref="survey_recruitment_form_p1_q8"/>
<record id="survey_recruitment_form_p1_q8_row4" model="survey.question.answer">
<field name="matrix_question_id" ref="survey_recruitment_form_p1_q8"/>
<field name="sequence">5</field>
<field name="value">Working with state of the art technology</field>
</record>
<record id="survey_recruitment_form_p1_q8_row5" model="survey.label">
<field name="question_id_2" ref="survey_recruitment_form_p1_q8"/>
<record id="survey_recruitment_form_p1_q8_row5" model="survey.question.answer">
<field name="matrix_question_id" ref="survey_recruitment_form_p1_q8"/>
<field name="sequence">6</field>
<field name="value">Office location</field>
</record>
<record id="survey_recruitment_form_p1_q8_row6" model="survey.label">
<field name="question_id_2" ref="survey_recruitment_form_p1_q8"/>
<record id="survey_recruitment_form_p1_q8_row6" model="survey.question.answer">
<field name="matrix_question_id" ref="survey_recruitment_form_p1_q8"/>
<field name="sequence">7</field>
<field name="value">Management quality</field>
</record>
<record id="survey_recruitment_form_p1_q8_row7" model="survey.label">
<field name="question_id_2" ref="survey_recruitment_form_p1_q8"/>
<record id="survey_recruitment_form_p1_q8_row7" model="survey.question.answer">
<field name="matrix_question_id" ref="survey_recruitment_form_p1_q8"/>
<field name="sequence">8</field>
<field name="value">Having freebies such as tea, coffee and stationery</field>
</record>
<record id="survey_recruitment_form_p1_q8_row8" model="survey.label">
<field name="question_id_2" ref="survey_recruitment_form_p1_q8"/>
<record id="survey_recruitment_form_p1_q8_row8" model="survey.question.answer">
<field name="matrix_question_id" ref="survey_recruitment_form_p1_q8"/>
<field name="sequence">9</field>
<field name="value">Getting perks such as free parking, gym passes</field>
</record>
Expand Down
1 change: 0 additions & 1 deletion addons/hr_recruitment_survey/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@

from . import hr_job
from . import hr_applicant
from . import survey_survey
8 changes: 2 additions & 6 deletions addons/hr_recruitment_survey/models/hr_applicant.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,9 @@ def action_start_survey(self):
else:
response = self.response_id
# grab the token of the response and start surveying
return self.survey_id.with_context(survey_token=response.token).action_start_survey()
return self.survey_id.action_start_survey(answer=response)

def action_print_survey(self):
""" If response is available then print this response otherwise print survey form (print template of the survey) """
self.ensure_one()
if not self.response_id:
return self.survey_id.action_print_survey()
else:
response = self.response_id
return self.survey_id.with_context(survey_token=response.token).action_print_survey()
return self.survey_id.action_print_survey(answer=self.response_id)
3 changes: 1 addition & 2 deletions addons/hr_recruitment_survey/models/hr_job.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import api, fields, models
from odoo import fields, models


class Job(models.Model):
_inherit = "hr.job"

survey_id = fields.Many2one(
'survey.survey', "Interview Form",
domain=[('category', '=', 'hr_recruitment')],
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")

def action_print_survey(self):
Expand Down
9 changes: 0 additions & 9 deletions addons/hr_recruitment_survey/models/survey_survey.py

This file was deleted.

4 changes: 2 additions & 2 deletions addons/hr_recruitment_survey/tests/test_recruitment_survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_start_survey(self):
action_start = self.job_sysadmin.action_start_survey()
self.assertEqual(action_start['type'], 'ir.actions.act_url')
self.assertNotEqual(self.job_sysadmin.response_id.id, False)
self.assertIn(self.job_sysadmin.response_id.token, action_start['url'])
self.assertIn(self.job_sysadmin.response_id.access_token, action_start['url'])
action_start_with_response = self.job_sysadmin.action_start_survey()
self.assertEqual(action_start_with_response, action_start)

Expand All @@ -42,4 +42,4 @@ def test_print_survey(self):
self.assertEqual(action_print['type'], 'ir.actions.act_url')
self.job_sysadmin.response_id = self.env['survey.user_input'].create({'survey_id': self.survey_sysadmin.id})
action_print_with_response = self.job_sysadmin.action_print_survey()
self.assertIn(self.job_sysadmin.response_id.token, action_print_with_response['url'])
self.assertIn(self.job_sysadmin.response_id.access_token, action_print_with_response['url'])
2 changes: 1 addition & 1 deletion addons/hr_recruitment_survey/views/hr_job_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<label for="survey_id" groups="survey.group_survey_user"/>
<div groups="survey.group_survey_user" class="o_row">
<field name="survey_id"
context="{'default_category': 'hr_recruitment', 'default_access_mode': 'token'}"/>
context="{'default_access_mode': 'token'}"/>
<button string="Display Interview Form" name="action_print_survey" type="object" attrs="{'invisible':[('survey_id','=',False)]}" class="oe_link"/>
</div>
</xpath>
Expand Down
13 changes: 0 additions & 13 deletions addons/hr_recruitment_survey/views/survey_survey_views.xml

This file was deleted.

6 changes: 3 additions & 3 deletions addons/hr_skills_survey/models/survey_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def _mark_done(self):

super(SurveyUserInput, self)._mark_done()

certificate_user_inputs = self.filtered(lambda user_input: user_input.survey_id.certificate and user_input.quizz_passed)
partner_has_completed = {user_input.partner_id.id: user_input.survey_id for user_input in certificate_user_inputs}
employees = self.env['hr.employee'].sudo().search([('user_id.partner_id', 'in', certificate_user_inputs.mapped('partner_id').ids)])
certification_user_inputs = self.filtered(lambda user_input: user_input.survey_id.certification and user_input.scoring_success)
partner_has_completed = {user_input.partner_id.id: user_input.survey_id for user_input in certification_user_inputs}
employees = self.env['hr.employee'].sudo().search([('user_id.partner_id', 'in', certification_user_inputs.mapped('partner_id').ids)])
for employee in employees:
line_type = self.env.ref('hr_skills_survey.resume_type_certification', raise_if_not_found=False)
survey = partner_has_completed.get(employee.user_id.partner_id.id)
Expand Down
4 changes: 3 additions & 1 deletion addons/survey/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
'data/survey_demo_user.xml',
'data/survey_demo_feedback.xml',
'data/survey_demo_certification.xml',
'data/survey.user_input_line.csv'
'data/survey_demo_quiz.xml',
'data/survey_demo_quiz_userinput.xml',
'data/survey.user_input.line.csv'
],
'installable': True,
'auto_install': False,
Expand Down
Loading