mirror of
https://github.com/bringout/oca-ocb-hr.git
synced 2026-04-27 17:32:01 +02:00
Initial commit: Hr packages
This commit is contained in:
commit
62531cd146
2820 changed files with 1432848 additions and 0 deletions
|
|
@ -0,0 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import hr_job
|
||||
from . import hr_applicant
|
||||
from . import survey_invite
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class Applicant(models.Model):
|
||||
_inherit = "hr.applicant"
|
||||
|
||||
survey_id = fields.Many2one('survey.survey', related='job_id.survey_id', string="Survey", readonly=True)
|
||||
response_id = fields.Many2one('survey.user_input', "Response", ondelete="set null", copy=False)
|
||||
response_state = fields.Selection(related='response_id.state', readonly=True)
|
||||
|
||||
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()
|
||||
return self.survey_id.action_print_survey(answer=self.response_id)
|
||||
|
||||
def action_send_survey(self):
|
||||
self.ensure_one()
|
||||
|
||||
# if an applicant does not already has associated partner_id create it
|
||||
if not self.partner_id:
|
||||
if not self.partner_name:
|
||||
raise UserError(_('You must define a Contact Name for this applicant.'))
|
||||
self.partner_id = self.env['res.partner'].create({
|
||||
'is_company': False,
|
||||
'type': 'private',
|
||||
'name': self.partner_name,
|
||||
'email': self.email_from,
|
||||
'phone': self.partner_phone,
|
||||
'mobile': self.partner_mobile
|
||||
})
|
||||
return self.survey_id.with_context(default_applicant_id=self.id, default_partner_ids=self.partner_id.ids).action_send_survey()
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
# 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_test_survey(self):
|
||||
self.ensure_one()
|
||||
action = self.survey_id.action_test_survey()
|
||||
return action
|
||||
|
||||
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
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.tools.misc import clean_context
|
||||
|
||||
|
||||
class SurveyInvite(models.TransientModel):
|
||||
_inherit = "survey.invite"
|
||||
|
||||
applicant_id = fields.Many2one('hr.applicant', string='Applicant')
|
||||
|
||||
def action_invite(self):
|
||||
self.ensure_one()
|
||||
if self.applicant_id:
|
||||
survey = self.survey_id.with_context(clean_context(self.env.context))
|
||||
|
||||
if not self.applicant_id.response_id:
|
||||
self.applicant_id.write({
|
||||
'response_id': survey._create_answer(partner=self.applicant_id.partner_id).id
|
||||
})
|
||||
|
||||
partner = self.applicant_id.partner_id
|
||||
survey_link = survey._get_html_link(title=survey.title)
|
||||
partner_link = partner._get_html_link()
|
||||
content = _('The survey %(survey_link)s has been sent to %(partner_link)s', survey_link=survey_link, partner_link=partner_link)
|
||||
body = '<p>%s</p>' % content
|
||||
self.applicant_id.message_post(body=body)
|
||||
return super().action_invite()
|
||||
|
||||
|
||||
class SurveyUserInput(models.Model):
|
||||
_inherit = "survey.user_input"
|
||||
|
||||
applicant_id = fields.One2many('hr.applicant', 'response_id', string='Applicant')
|
||||
|
||||
def _mark_done(self):
|
||||
odoobot = self.env.ref('base.partner_root')
|
||||
for user_input in self:
|
||||
if user_input.applicant_id:
|
||||
body = _('The applicant "%s" has finished the survey.', user_input.applicant_id.partner_name)
|
||||
user_input.applicant_id.message_post(body=body, author_id=odoobot.id)
|
||||
return super()._mark_done()
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, values_list):
|
||||
if 'default_applicant_id' in self.env.context:
|
||||
self = self.with_context(default_applicant_id=False)
|
||||
return super().create(values_list)
|
||||
Loading…
Add table
Add a link
Reference in a new issue