From 40146bff7f68c71ddca65b3d14497565750f2fa1 Mon Sep 17 00:00:00 2001 From: Prakash Prajapati Date: Wed, 29 Jul 2020 09:49:38 +0000 Subject: [PATCH] [FIX] hr_recruitment: Include archived applicants on job's button count Currently in the job's stat button and on kanban button the archived applicants are not counted and not display while click on button. So in this commit, count of the archived applicant's in form views and show the archived applicants when clicked on stat button. also curently there is no indication for applicant is refused or not so in this commit add badge on kanban and form for archieve(refused) applicant. we should not count the archived applicantion in the kanban button. closes odoo/odoo#55755 Taskid: 2308448 Closes: #55104 X-original-commit: d272d0bbaa5847753236bbee11bff94683cb66f4 Signed-off-by: Yannick Tivisse (yti) --- addons/hr_recruitment/models/hr_job.py | 7 +++++++ addons/hr_recruitment/views/hr_recruitment_views.xml | 7 ++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/addons/hr_recruitment/models/hr_job.py b/addons/hr_recruitment/models/hr_job.py index aefd550d694..7094d529721 100644 --- a/addons/hr_recruitment/models/hr_job.py +++ b/addons/hr_recruitment/models/hr_job.py @@ -23,6 +23,7 @@ class Job(models.Model): help="Address where employees are working") application_ids = fields.One2many('hr.applicant', 'job_id', "Applications") application_count = fields.Integer(compute='_compute_application_count', string="Application Count") + all_application_count = fields.Integer(compute='_compute_all_application_count', string="All Application Count") new_application_count = fields.Integer( compute='_compute_new_application_count', string="New Application", help="Number of applications that are new in the flow (typically at first step of the flow)") @@ -74,6 +75,12 @@ class Job(models.Model): job.document_ids = result[job.id] job.documents_count = len(job.document_ids) + def _compute_all_application_count(self): + read_group_result = self.env['hr.applicant'].with_context(active_test=False).read_group([('job_id', 'in', self.ids)], ['job_id'], ['job_id']) + result = dict((data['job_id'][0], data['job_id_count']) for data in read_group_result) + for job in self: + job.all_application_count = result.get(job.id, 0) + def _compute_application_count(self): read_group_result = self.env['hr.applicant'].read_group([('job_id', 'in', self.ids)], ['job_id'], ['job_id']) result = dict((data['job_id'][0], data['job_id_count']) for data in read_group_result) diff --git a/addons/hr_recruitment/views/hr_recruitment_views.xml b/addons/hr_recruitment/views/hr_recruitment_views.xml index 111c13ff33f..a71088997b2 100644 --- a/addons/hr_recruitment/views/hr_recruitment_views.xml +++ b/addons/hr_recruitment/views/hr_recruitment_views.xml @@ -91,7 +91,7 @@ - + @@ -285,6 +285,7 @@