summaryrefslogtreecommitdiff
path: root/addons/hr_recruitment_survey/models/hr_job.py
blob: 60e7557e550e9fac9cb4efb5f8dc9266f9ab143e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import fields, models, _


class Job(models.Model):
    _inherit = "hr.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")

    def action_print_survey(self):
        return self.survey_id.action_print_survey()

    def action_new_survey(self):
        self.ensure_one()
        survey = self.env['survey.survey'].create({
            'title': _("Interview Form : %s") % self.name,
        })
        self.write({'survey_id': survey.id})

        action = {
                'name': _('Survey'),
                'view_mode': 'form,tree',
                'res_model': 'survey.survey',
                'type': 'ir.actions.act_window',
                'context': {'form_view_initial_mode': 'edit'},
                'res_id': survey.id,
            }

        return action