Skip to content
Snippets Groups Projects
Commit 72072263 authored by Thomas Lefebvre (thle)'s avatar Thomas Lefebvre (thle)
Browse files

[FIX] website_hr_recruitment: prevent applying for unpublished job


Issue:
------
When we have the link to the form to apply for a job,
even if the job is not published, we can still apply.

Solution:
---------
Check that the job is published before the creation of the record
in the `website_form_input_filter`.

opw-3331717

closes odoo/odoo#125141

X-original-commit: 547355a5
Signed-off-by: default avatarKevin Baptiste <kba@odoo.com>
parent e973ee01
Branches
Tags
No related merge requests found
......@@ -698,6 +698,13 @@ msgid ""
"displayed on the main Jobs' list page."
msgstr ""
#. module: website_hr_recruitment
#. odoo-python
#: code:addons/website_hr_recruitment/models/hr_recruitment.py:0
#, python-format
msgid "You cannot apply for this job."
msgstr ""
#. module: website_hr_recruitment
#: model_terms:ir.ui.view,arch_db:website_hr_recruitment.thankyou_ir_ui_view
#: model_terms:website.page,arch_db:website_hr_recruitment.thankyou
......
......@@ -4,7 +4,7 @@
from werkzeug import urls
from odoo import api, fields, models, _
from odoo.exceptions import UserError
class RecruitmentSource(models.Model):
_inherit = 'hr.recruitment.source'
......@@ -34,6 +34,9 @@ class Applicant(models.Model):
name = '%s - %s' % (values['partner_name'], applicant_job) if applicant_job else _("%s's Application", values['partner_name'])
values.setdefault('name', name)
if values.get('job_id'):
job = self.env['hr.job'].browse(values.get('job_id'))
if not job.sudo().website_published:
raise UserError(_("You cannot apply for this job."))
stage = self.env['hr.recruitment.stage'].sudo().search([
('fold', '=', False),
'|', ('job_ids', '=', False), ('job_ids', '=', values['job_id']),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment