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_application_count
| Inputs | Method | Outputs |
|---|---|---|
|
- """ - The field application_count is only used on the form view. - Thus, using ORM rather then querying, should not make much - difference in terms of performance, while being more readable and secure. - """ - if not any(self._ids): - for applicant in self: - domain = applicant._get_similar_applicants_domain() - if domain: - applicant.application_count = max(0, self.env["hr.applicant"].with_context(active_test=False).search_count(domain) - 1) - else: - applicant.application_count = 0 - return - self.flush_recordset(['email_normalized', 'partner_phone_sanitized', 'partner_mobile_sanitized']) - self.env.cr.execute(""" - SELECT - id, - ( - SELECT COUNT(*) - FROM hr_applicant AS sub - WHERE a.id != sub.id - AND ((a.email_normalized <> '' AND sub.email_normalized = a.email_normalized) - OR (a.partner_mobile_sanitized <> '' AND a.partner_mobile_sanitized = sub.partner_mobile_sanitized) - OR (a.partner_mobile_sanitized <> '' AND a.partner_mobile_sanitized = sub.partner_phone_sanitized) - OR (a.partner_phone_sanitized <> '' AND a.partner_phone_sanitized = sub.partner_mobile_sanitized) - OR (a.partner_phone_sanitized <> '' AND a.partner_phone_sanitized = sub.partner_phone_sanitized)) - ) AS similar_applicants - FROM hr_applicant AS a - WHERE id IN %(ids)s - """, {'ids': tuple(self._origin.ids)}) - query_results = self.env.cr.dictfetchall() - mapped_data = {result['id']: result['similar_applicants'] for result in query_results} - for applicant in self: - applicant.application_count = mapped_data.get(applicant.id, 0) |
|
