[FIX] hr_applicant: Domain stages and website applicant

When we change job_id on an applicant, we want that the stages above
change (if there arre special stage for this job).
On website recruitment, a traceback prevent to complete the form to
apply for a job.

closes odoo/odoo#34981

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
jbm-odoo
2019-07-18 12:24:57 +00:00
parent 46f2f04b85
commit f9b24cec17
2 changed files with 2 additions and 9 deletions
@@ -4,7 +4,6 @@
from odoo import api, fields, models, SUPERUSER_ID
from odoo.tools.translate import _
from odoo.exceptions import UserError
from odoo.osv import expression
AVAILABLE_PRIORITIES = [
('0', 'Normal'),
@@ -113,12 +112,6 @@ class Applicant(models.Model):
company_id = self.env.company
return company_id
def _get_stage_id_domain(self):
domain = [('job_ids', '=', False)]
if self.job_id:
domain = expression.OR([domain, [('job_ids', 'in', self.job_id)]])
return domain
name = fields.Char("Subject / Application Name", required=True)
active = fields.Boolean("Active", default=True, help="If the active field is set to false, it will allow you to hide the case without removing it.")
description = fields.Text("Description")
@@ -127,7 +120,7 @@ class Applicant(models.Model):
partner_id = fields.Many2one('res.partner', "Contact", copy=False)
create_date = fields.Datetime("Creation Date", readonly=True, index=True)
stage_id = fields.Many2one('hr.recruitment.stage', 'Stage', ondelete='restrict', tracking=True,
domain=_get_stage_id_domain,
domain="['|', ('job_ids', '=', False), ('job_ids', '=', job_id)]",
copy=False, index=True,
group_expand='_read_group_stage_ids',
default=_default_stage_id)
@@ -118,7 +118,7 @@
<div class="row mt-3">
<section id="forms" class="col">
<span class="hidden" data-for="hr_recruitment_form" t-att-data-values="{'department_id': job and job.department_id.id or False, 'job_id': job and job.id or False}" />
<span class="hidden" data-for="hr_recruitment_form" t-att-data-values="{'department_id': job and job.department_id.id or '', 'job_id': job and job.id or ''}" />
<form id="hr_recruitment_form" action="/website_form/" method="post" class="s_website_form" enctype="multipart/form-data" data-model_name="hr.applicant" data-success_page="/job-thank-you" hide-change-model="true">
<div class="form-group row form-field o_website_form_required_custom">
<div class="col-lg-3 col-md-4 text-right">