Recruitment changes
This commit is contained in:
parent
426b3d71a4
commit
2aabe1e7c6
|
|
@ -335,59 +335,62 @@ class WebsiteJobHrRecruitment(WebsiteHrRecruitment):
|
||||||
@http.route('/website_hr_recruitment_extended/check_recent_application', type='json', auth="public", website=True)
|
@http.route('/website_hr_recruitment_extended/check_recent_application', type='json', auth="public", website=True)
|
||||||
def check_recent_application(self, value, job_id):
|
def check_recent_application(self, value, job_id):
|
||||||
# Function to check if the applicant has an existing record based on email, phone, or linkedin
|
# Function to check if the applicant has an existing record based on email, phone, or linkedin
|
||||||
def refused_applicants_condition(applicant):
|
if value:
|
||||||
return not applicant.active \
|
def refused_applicants_condition(applicant):
|
||||||
and applicant.hr_job_recruitment.id == int(job_id) \
|
return not applicant.active \
|
||||||
and applicant.create_date >= (datetime.now() - relativedelta(months=6))
|
and applicant.hr_job_recruitment.id == int(job_id) \
|
||||||
# Search for applicants with the same email, phone, or linkedin (only if the value is not False/None)
|
and applicant.create_date >= (datetime.now() - relativedelta(months=6))
|
||||||
applicants_with_similar_info = http.request.env['hr.applicant'].sudo().search([
|
# Search for applicants with the same email, phone, or linkedin (only if the value is not False/None)
|
||||||
('hr_job_recruitment','=',int(job_id)),
|
applicants_with_similar_info = http.request.env['hr.applicant'].sudo().search([
|
||||||
'|',
|
('hr_job_recruitment','=',int(job_id)),
|
||||||
('email_normalized', '=', email_normalize(value)),
|
'|',
|
||||||
'|',
|
('email_normalized', '=', email_normalize(value)),
|
||||||
('partner_phone', '=', value),
|
'|',
|
||||||
('linkedin_profile', '=ilike', value),
|
('partner_phone', '=', value),
|
||||||
], order='create_date DESC')
|
('linkedin_profile', '=ilike', value),
|
||||||
|
], order='create_date DESC')
|
||||||
|
|
||||||
if not applicants_with_similar_info:
|
if not applicants_with_similar_info:
|
||||||
return {'message':None}
|
return {'message':None}
|
||||||
# Group applications by their status
|
# Group applications by their status
|
||||||
applications_by_status = applicants_with_similar_info.grouped('application_status')
|
applications_by_status = applicants_with_similar_info.grouped('application_status')
|
||||||
|
|
||||||
# Check for refused applicants with the same value within the last 6 months
|
# Check for refused applicants with the same value within the last 6 months
|
||||||
refused_applicants = applications_by_status.get('refused', http.request.env['hr.applicant'])
|
refused_applicants = applications_by_status.get('refused', http.request.env['hr.applicant'])
|
||||||
if any(applicant for applicant in refused_applicants if refused_applicants_condition(applicant)):
|
if any(applicant for applicant in refused_applicants if refused_applicants_condition(applicant)):
|
||||||
return {
|
|
||||||
'message': _(
|
|
||||||
'We\'ve found a previous closed application in our system within the last 6 months.'
|
|
||||||
' Please consider before applying in order not to duplicate efforts.'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check for ongoing applications with the same value
|
|
||||||
ongoing_applications = applications_by_status.get('ongoing', [])
|
|
||||||
if ongoing_applications:
|
|
||||||
ongoing_application = ongoing_applications[0]
|
|
||||||
if ongoing_application.hr_job_recruitment.id == int(job_id):
|
|
||||||
recruiter_contact = "" if not ongoing_application.user_id else _(
|
|
||||||
' In case of issue, contact %(contact_infos)s',
|
|
||||||
contact_infos=", ".join(
|
|
||||||
[value for value in itemgetter('name', 'email', 'phone')(ongoing_application.user_id) if value]
|
|
||||||
))
|
|
||||||
|
|
||||||
error_message = 'An application already exists for %s Duplicates might be rejected. %s '%(value,recruiter_contact)
|
|
||||||
print(error_message)
|
|
||||||
return {
|
return {
|
||||||
'message': _(error_message)
|
'message': _(
|
||||||
|
'We\'ve found a previous closed application in our system within the last 6 months.'
|
||||||
|
' Please consider before applying in order not to duplicate efforts.'
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
# If no existing application found, show the following message
|
# Check for ongoing applications with the same value
|
||||||
return {
|
ongoing_applications = applications_by_status.get('ongoing', [])
|
||||||
'message': _(
|
if ongoing_applications:
|
||||||
'We found a recent application with a similar name, email, phone number.'
|
ongoing_application = ongoing_applications[0]
|
||||||
' You can continue if it\'s not a mistake.'
|
if ongoing_application.hr_job_recruitment.id == int(job_id):
|
||||||
)
|
recruiter_contact = "" if not ongoing_application.user_id else _(
|
||||||
}
|
' In case of issue, contact %(contact_infos)s',
|
||||||
|
contact_infos=", ".join(
|
||||||
|
[value for value in itemgetter('name', 'email', 'phone')(ongoing_application.user_id) if value]
|
||||||
|
))
|
||||||
|
|
||||||
|
error_message = 'An application already exists for %s Duplicates might be rejected. %s '%(value,recruiter_contact)
|
||||||
|
print(error_message)
|
||||||
|
return {
|
||||||
|
'message': _(error_message)
|
||||||
|
}
|
||||||
|
|
||||||
|
# If no existing application found, show the following message
|
||||||
|
return {
|
||||||
|
'message': _(
|
||||||
|
'We found a recent application with a similar name, email, phone number.'
|
||||||
|
' You can continue if it\'s not a mistake.'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
return {'message': None}
|
||||||
|
|
||||||
def _should_log_authenticate_message(self, record):
|
def _should_log_authenticate_message(self, record):
|
||||||
if record._name == "hr.applicant" and not request.session.uid:
|
if record._name == "hr.applicant" and not request.session.uid:
|
||||||
|
|
@ -395,7 +398,6 @@ class WebsiteJobHrRecruitment(WebsiteHrRecruitment):
|
||||||
return super()._should_log_authenticate_message(record)
|
return super()._should_log_authenticate_message(record)
|
||||||
|
|
||||||
def extract_data(self, model, values):
|
def extract_data(self, model, values):
|
||||||
|
|
||||||
candidate = False
|
candidate = False
|
||||||
extracted_resume = values.pop('resume_base64', None)
|
extracted_resume = values.pop('resume_base64', None)
|
||||||
current_ctc = values.pop('current_ctc', None)
|
current_ctc = values.pop('current_ctc', None)
|
||||||
|
|
@ -422,6 +424,21 @@ class WebsiteJobHrRecruitment(WebsiteHrRecruitment):
|
||||||
total_experience = int(experience_years)
|
total_experience = int(experience_years)
|
||||||
total_experience_type = 'year'
|
total_experience_type = 'year'
|
||||||
|
|
||||||
|
if extracted_resume:
|
||||||
|
attachment = request.env.ref("hr_recruitment_extended.employee_recruitment_attachments_preview")
|
||||||
|
file = attachment.sudo().write({
|
||||||
|
'datas': extracted_resume,
|
||||||
|
})
|
||||||
|
if file:
|
||||||
|
resume_type = attachment.mimetype
|
||||||
|
resume_name = attachment.name
|
||||||
|
else:
|
||||||
|
resume_type = ''
|
||||||
|
resume_name = ''
|
||||||
|
else:
|
||||||
|
resume_type = ''
|
||||||
|
resume_name = ''
|
||||||
|
|
||||||
skill_dict = {key: ast.literal_eval(value) for key,value in values.items() if "skill" in key and value != '0'}
|
skill_dict = {key: ast.literal_eval(value) for key,value in values.items() if "skill" in key and value != '0'}
|
||||||
|
|
||||||
if model.model == 'hr.applicant':
|
if model.model == 'hr.applicant':
|
||||||
|
|
@ -435,6 +452,7 @@ class WebsiteJobHrRecruitment(WebsiteHrRecruitment):
|
||||||
'|', ('email_from', '=', partner_email),
|
'|', ('email_from', '=', partner_email),
|
||||||
('partner_phone', '=', partner_phone),
|
('partner_phone', '=', partner_phone),
|
||||||
], limit=1)
|
], limit=1)
|
||||||
|
|
||||||
if candidate:
|
if candidate:
|
||||||
candidate.sudo().write({
|
candidate.sudo().write({
|
||||||
'partner_name': partner_name,
|
'partner_name': partner_name,
|
||||||
|
|
@ -442,7 +460,9 @@ class WebsiteJobHrRecruitment(WebsiteHrRecruitment):
|
||||||
'email_from': partner_email,
|
'email_from': partner_email,
|
||||||
'partner_phone': partner_phone,
|
'partner_phone': partner_phone,
|
||||||
'type_id': int(degree) if degree.isdigit() else False,
|
'type_id': int(degree) if degree.isdigit() else False,
|
||||||
'resume': extracted_resume
|
'resume': extracted_resume,
|
||||||
|
'resume_type': resume_type,
|
||||||
|
'resume_name': resume_name,
|
||||||
})
|
})
|
||||||
if not candidate:
|
if not candidate:
|
||||||
candidate = request.env['hr.candidate'].sudo().create({
|
candidate = request.env['hr.candidate'].sudo().create({
|
||||||
|
|
@ -451,7 +471,9 @@ class WebsiteJobHrRecruitment(WebsiteHrRecruitment):
|
||||||
'partner_phone': partner_phone,
|
'partner_phone': partner_phone,
|
||||||
'alternate_phone': alternate_phone,
|
'alternate_phone': alternate_phone,
|
||||||
'type_id': int(degree) if degree.isdigit() else False,
|
'type_id': int(degree) if degree.isdigit() else False,
|
||||||
'resume': extracted_resume
|
'resume': extracted_resume,
|
||||||
|
'resume_type': resume_type,
|
||||||
|
'resume_name': resume_name,
|
||||||
})
|
})
|
||||||
|
|
||||||
if len(skill_dict) > 0:
|
if len(skill_dict) > 0:
|
||||||
|
|
@ -466,8 +488,9 @@ class WebsiteJobHrRecruitment(WebsiteHrRecruitment):
|
||||||
candidate_skills['skill_type_id'] = skill_type_id
|
candidate_skills['skill_type_id'] = skill_type_id
|
||||||
# skill = request.env['hr.candidate.skill'].sudo().create(candidate_skills)
|
# skill = request.env['hr.candidate.skill'].sudo().create(candidate_skills)
|
||||||
# candidate_skills_list.append(skill.id)
|
# candidate_skills_list.append(skill.id)
|
||||||
if candidate.candidate_skill_ids and candidate_skills['skill_id'] not in candidate.candidate_skill_ids.skill_id.ids:
|
if candidate.candidate_skill_ids:
|
||||||
candidate.write({'candidate_skill_ids':[(0,4,candidate_skills)]})
|
if candidate_skills['skill_id'] not in candidate.candidate_skill_ids.skill_id.ids:
|
||||||
|
candidate.write({'candidate_skill_ids':[(0,4,candidate_skills)]})
|
||||||
else:
|
else:
|
||||||
candidate.write({'candidate_skill_ids':[(0,4,candidate_skills)]})
|
candidate.write({'candidate_skill_ids':[(0,4,candidate_skills)]})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue