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_is_applicant_in_pool

Inputs Method Outputs
"""
        Computes if an application is linked to a talent pool or not.
        An application can either be directly or indirectly linked to a talent pool.
        Direct link:
            - 1. Application has talent_pool_ids set, meaning this application
                is a talent pool application, or talent for short.
            - 2. Application has pool_applicant_id set, meaning this application
            is a copy or directly linked to a talent (scenario 1)

        Indirect link:
            - 3. Application shares a phone number, email, or linkedin with a
                direclty linked application.

        Note: While possible, linking an application to a pool through linking
        it to an indirect link is currently excluded from the implementation
        for technical reasons.
        """
direct = self.filtered(lambda a: a.talent_pool_ids or a.pool_applicant_id)
direct.is_applicant_in_pool = True
indirect = self - direct
if not indirect:
            return
all_emails = {a.email_normalized for a in indirect if a.email_normalized}
all_phones = {a.partner_phone_sanitized for a in indirect if a.partner_phone_sanitized}
all_linkedins = {a.linkedin_profile for a in indirect if a.linkedin_profile}
epl_domain = Domain.FALSE
if all_emails:
            epl_domain |= Domain("email_normalized", "in", list(all_emails))
if all_phones:
            epl_domain |= Domain("partner_phone_sanitized", "in", list(all_phones))
if all_linkedins:
            epl_domain |= Domain("linkedin_profile", "in", list(all_linkedins))
pool_domain = Domain(["|", ("talent_pool_ids", "!=", False), ("pool_applicant_id", "!=", False)])
domain = pool_domain & epl_domain
in_pool_applicants = self.env["hr.applicant"].with_context(active_test=True).search(domain)
in_pool_data = {"emails": set(), "phones": set(), "linkedins": set()}
for applicant in in_pool_applicants:
            if applicant.email_normalized:
                in_pool_data["emails"].add(applicant.email_normalized)
            if applicant.partner_phone_sanitized:
                in_pool_data["phones"].add(applicant.partner_phone_sanitized)
            if applicant.linkedin_profile:
                in_pool_data["linkedins"].add(applicant.linkedin_profile)
for applicant in indirect:
            applicant.is_applicant_in_pool = (
                applicant.email_normalized in in_pool_data["emails"]
                or applicant.partner_phone_sanitized in in_pool_data["phones"]
                or applicant.linkedin_profile in in_pool_data["linkedins"]
            )

Back to entity