[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#125429 X-original-commit: d68eab464654441d51f618c5d3d036999316ed7f Signed-off-by: Kevin Baptiste <kba@odoo.com> Signed-off-by: Lefebvre Thomas (thle) <thle@odoo.com>
This commit is contained in:
@@ -766,6 +766,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
|
||||
msgid "Your <b>contact</b> information is:"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import models, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class Applicant(models.Model):
|
||||
@@ -14,6 +15,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']),
|
||||
|
||||
Reference in New Issue
Block a user