Debian Codegraph @

addons/hr_recruitment_survey/models/survey_survey.py

raw symbols SCIP
1 # Part of Odoo. See LICENSE file for full copyright and licensing details.
2
3 from odoo import api, fields, models
4
5
6 class SurveySurvey(models.Model):
7 _inherit = 'survey.survey'
8
9 survey_type = fields.Selection(selection_add=[('recruitment', 'Recruitment')], ondelete={'recruitment': 'set default'})
10 hr_job_ids = fields.One2many("hr.job", "survey_id", string="Job Position")
11
12 @api.depends('survey_type')
13 @api.depends_context('uid')
14 def _compute_allowed_survey_types(self):
15 super()._compute_allowed_survey_types()
16 if self.env.user.has_group('hr_recruitment.group_hr_recruitment_interviewer') or \
17 self.env.user.has_group('survey.group_survey_user'):
18 self.allowed_survey_types = (self.allowed_survey_types or []) + ['recruitment']
19
20 def get_formview_id(self, access_uid=None):
21 if self.survey_type == 'recruitment':
22 access_user = self.env['res.users'].browse(access_uid) if access_uid else self.env.user
23 if not access_user.has_group('survey.group_survey_user'):
24 if view := self.env.ref('hr_recruitment_survey.survey_survey_view_form', raise_if_not_found=False):
25 return view.id
26 return super().get_formview_id(access_uid=access_uid)
27
28 def action_survey_user_input_completed(self):
29 action = super().action_survey_user_input_completed()
30 if self.survey_type == 'recruitment':
31 action.update({
32 'domain': [('survey_id.survey_type', '=', 'recruitment')]
33 })
34 return action