From 3af0b3387f84f7a4f66dc87ba5644f150ce1b40e Mon Sep 17 00:00:00 2001 From: Nicolas Seinlet Date: Fri, 9 Aug 2019 08:22:54 +0000 Subject: [PATCH] [IMP] hr_recruitment: use search_count to count closes odoo/odoo#35584 Signed-off-by: Christophe Simonis --- addons/hr_recruitment/models/hr_job.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/addons/hr_recruitment/models/hr_job.py b/addons/hr_recruitment/models/hr_job.py index a7c13066500..00079bc299b 100644 --- a/addons/hr_recruitment/models/hr_job.py +++ b/addons/hr_recruitment/models/hr_job.py @@ -86,13 +86,10 @@ class Job(models.Model): ('job_id', '=', self.id)], order='sequence asc', limit=1) def _compute_new_application_count(self): - first_stages = {job.id: job._get_first_stage().id for job in self} - mapped_data = dict.fromkeys(self.ids, 0) - for applicant in self.mapped('application_ids'): - if applicant.stage_id.id == first_stages.get(applicant.job_id.id): - mapped_data[applicant.job_id.id] += 1 for job in self: - job.new_application_count = mapped_data.get(job.id) + job.new_application_count = self.env["hr.applicant"].search_count( + [("job_id", "=", job.id), ("stage_id", "=", job._get_first_stage().id)] + ) def get_alias_model_name(self, vals): return 'hr.applicant'