diff --git a/addons/website_hr_recruitment/i18n/website_hr_recruitment.pot b/addons/website_hr_recruitment/i18n/website_hr_recruitment.pot index 043dd935d88..651e4e8c1b1 100644 --- a/addons/website_hr_recruitment/i18n/website_hr_recruitment.pot +++ b/addons/website_hr_recruitment/i18n/website_hr_recruitment.pot @@ -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 contact information is:" diff --git a/addons/website_hr_recruitment/models/hr_applicant.py b/addons/website_hr_recruitment/models/hr_applicant.py index 99a4e968d63..4e1ed0641fc 100644 --- a/addons/website_hr_recruitment/models/hr_applicant.py +++ b/addons/website_hr_recruitment/models/hr_applicant.py @@ -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']),