From 7fc04795a89850447f93c29e1aa8bf54f285238f Mon Sep 17 00:00:00 2001 From: Kevin Baptiste Date: Fri, 28 Apr 2023 11:46:57 +0000 Subject: [PATCH] [FIX] hr_recruitment: count archived/refused for other applications The fix introduced in odoo/odoo#119017 was no longer taking into account the refused/archived applications, showing a negative number in some cases. task-3293460 closes odoo/odoo#120426 X-original-commit: 55e279f96c9d878103657f437222066ae74dcf0f Signed-off-by: Kevin Baptiste --- addons/hr_recruitment/models/hr_applicant.py | 4 ++-- addons/hr_recruitment/tests/test_recruitment.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/hr_recruitment/models/hr_applicant.py b/addons/hr_recruitment/models/hr_applicant.py index 6890d2e5df9..c869ac1f912 100644 --- a/addons/hr_recruitment/models/hr_applicant.py +++ b/addons/hr_recruitment/models/hr_applicant.py @@ -137,7 +137,7 @@ class Applicant(models.Model): for applicant in self: domain = applicant._get_similar_applicants_domain() if domain: - applicant.application_count = self.env["hr.applicant"].search_count(domain) - 1 + applicant.application_count = self.env["hr.applicant"].with_context(active_test=False).search_count(domain) - 1 else: applicant.application_count = 0 @@ -416,7 +416,7 @@ class Applicant(models.Model): other_applicants = self.env['hr.applicant'] domain = self._get_similar_applicants_domain() if domain: - other_applicants = self.env['hr.applicant'].search(domain) + other_applicants = self.env['hr.applicant'].with_context(active_test=False).search(domain) return { 'type': 'ir.actions.act_window', 'name': _('Job Applications'), diff --git a/addons/hr_recruitment/tests/test_recruitment.py b/addons/hr_recruitment/tests/test_recruitment.py index 2cbf8e03bd6..8a059dc6ae3 100644 --- a/addons/hr_recruitment/tests/test_recruitment.py +++ b/addons/hr_recruitment/tests/test_recruitment.py @@ -33,6 +33,7 @@ class TestRecruitment(TransactionCase): """ A, B, C, D, E, F, _ = self.env['hr.applicant'].create([ { + 'active': False, # Refused/archived application should still count 'name': 'Application A', 'email_from': 'abc@odoo.com', 'partner_phone': '123',