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 @@