From c32cdf0e7ca7fa1cf40392c0112dbd6dd35b4381 Mon Sep 17 00:00:00 2001 From: "Thomas Lefebvre (thle)" Date: Fri, 15 Sep 2023 15:23:52 +0200 Subject: [PATCH] [FIX] website_hr_recruitment: apply for an unpublished job internally Issue: ------ Since the commit [^1], it was no longer possible to apply for a job via the website if it is unpublished. This made it impossible to apply for internal job offers. Solution: --------- Since the commit [^2], it is possible to distinguish between unpublished and archived job offers. The behavior after this commit is as follows: - if the job is published --> everybody can apply; - if the job is not published --> everybody can apply but the job page is hidden; We need to know it, i.e. for internal use only. - if the job is archived --> nobody can apply; There is an error message "the job offer has been closed". [^1]: https://github.com/odoo/odoo/commit/72072263ae01a8bea01c7fead000159ae9d060d2 [^2]: https://github.com/odoo/odoo/commit/6c5f38ae37e9c1014bfa93dd82ffc6a3b31f0bd5 opw-3508043 closes odoo/odoo#135791 X-original-commit: abb3afc0c46dd13e0ef8b10ae80d6534a938b3ad Signed-off-by: Sofie Gvaladze (sgv) Signed-off-by: Thomas Lefebvre (thle) --- addons/website_hr_recruitment/i18n/website_hr_recruitment.pot | 2 +- addons/website_hr_recruitment/models/hr_applicant.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/website_hr_recruitment/i18n/website_hr_recruitment.pot b/addons/website_hr_recruitment/i18n/website_hr_recruitment.pot index 279286b07c7..b82f88cab5c 100644 --- a/addons/website_hr_recruitment/i18n/website_hr_recruitment.pot +++ b/addons/website_hr_recruitment/i18n/website_hr_recruitment.pot @@ -770,7 +770,7 @@ msgstr "" #. odoo-python #: code:addons/website_hr_recruitment/models/hr_recruitment.py:0 #, python-format -msgid "You cannot apply for this job." +msgid "The job offer has been closed." msgstr "" #. module: website_hr_recruitment diff --git a/addons/website_hr_recruitment/models/hr_applicant.py b/addons/website_hr_recruitment/models/hr_applicant.py index 4e1ed0641fc..763575c67e8 100644 --- a/addons/website_hr_recruitment/models/hr_applicant.py +++ b/addons/website_hr_recruitment/models/hr_applicant.py @@ -16,8 +16,8 @@ class Applicant(models.Model): 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.")) + if not job.sudo().active: + raise UserError(_("The job offer has been closed.")) stage = self.env['hr.recruitment.stage'].sudo().search([ ('fold', '=', False), '|', ('job_ids', '=', False), ('job_ids', '=', values['job_id']),