Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Recruitment

Entity: hr.applicant

Compute Method: _compute_talent_pool_count

View 20.0
Inputs Method Outputs
  • pool_applicant_id
  • pool_applicant_id.talent_pool_ids
  • email_normalized
  • partner_phone_sanitized
  • linkedin_profile
  • email_from
+ """
+         This method will find the amount of talent pools the current application is associated with.
+         An application can either be associated directly with a talent pool through talent_pool_ids
+         and/or pool_applicant_id.talent_pool_ids or indirectly by having the same email, phone
+         number or linkedin as a directly linked application.
+         """
+ pool_applicants = self.filtered("is_applicant_in_pool")
+ (self - pool_applicants).talent_pool_count = 0
+ if not pool_applicants:
+             return
+ directly_linked = pool_applicants.filtered("pool_applicant_id")
+ for applicant in directly_linked:
+             # All talents(applications with talent_pool_ids set) have a pool_applicant_id set to
+             # themselves which is the reason we only look for that instead of searching for all
+             # applications with talent_pool_ids and all applications with pool_applicant_id seperately
+             applicant.talent_pool_count = len(applicant.pool_applicant_id.talent_pool_ids)
+ indirectly_linked = pool_applicants - directly_linked
+ if not indirectly_linked:
+             return
+ domain = self._get_similar_applicants_domain() & Domain(["|", ("talent_pool_ids", "!=", False), ("pool_applicant_id", "!=", False)])
+ in_pool_applicants = self.env["hr.applicant"].with_context(active_test=False).search(domain)
+ in_pool_emails = defaultdict(int)
+ in_pool_phones = defaultdict(int)
+ in_pool_linkedins = defaultdict(int)
+ for applicant in in_pool_applicants:
+             talent_pool_count = len(applicant.pool_applicant_id.talent_pool_ids)
+             if applicant.email_normalized:
+                 in_pool_emails[applicant.email_normalized] = talent_pool_count
+             if applicant.partner_phone_sanitized:
+                 in_pool_phones[applicant.partner_phone_sanitized] = talent_pool_count
+             if applicant.linkedin_profile:
+                 in_pool_linkedins[applicant.linkedin_profile] = talent_pool_count
+ for applicant in indirectly_linked:
+             if applicant.email_from and in_pool_emails[applicant.email_normalized]:
+                 applicant.talent_pool_count = in_pool_emails[applicant.email_normalized]
+             elif applicant.partner_phone_sanitized and in_pool_phones[applicant.partner_phone_sanitized]:
+                 applicant.talent_pool_count = in_pool_phones[applicant.partner_phone_sanitized]
+             elif applicant.linkedin_profile and in_pool_linkedins[applicant.linkedin_profile]:
+                 applicant.talent_pool_count = in_pool_linkedins[applicant.linkedin_profile]
+             else:
+                 applicant.talent_pool_count = 0
  • talent_pool_count

Back to entity