commit
45fe2f932d
|
|
@ -164,7 +164,6 @@ class website_hr_recruitment_applications(http.Controller):
|
||||||
@http.route(['/FTPROTECH/submit/<int:applicant_id>/JoinForm'], type='http', auth="public",
|
@http.route(['/FTPROTECH/submit/<int:applicant_id>/JoinForm'], type='http', auth="public",
|
||||||
methods=['POST'], website=True, csrf=False)
|
methods=['POST'], website=True, csrf=False)
|
||||||
def process_employee_joining_form(self,applicant_id,**post):
|
def process_employee_joining_form(self,applicant_id,**post):
|
||||||
|
|
||||||
applicant = request.env['hr.applicant'].sudo().browse(applicant_id)
|
applicant = request.env['hr.applicant'].sudo().browse(applicant_id)
|
||||||
if not applicant.exists():
|
if not applicant.exists():
|
||||||
return request.not_found() # Return 404 if applicant doesn't exist
|
return request.not_found() # Return 404 if applicant doesn't exist
|
||||||
|
|
@ -284,18 +283,37 @@ class website_hr_recruitment_applications(http.Controller):
|
||||||
applicant.write(applicant_data)
|
applicant.write(applicant_data)
|
||||||
template = request.env.ref('hr_recruitment_extended.email_template_post_onboarding_form_user_submit',
|
template = request.env.ref('hr_recruitment_extended.email_template_post_onboarding_form_user_submit',
|
||||||
raise_if_not_found=False)
|
raise_if_not_found=False)
|
||||||
|
# Get HR managers with HR department
|
||||||
group = request.env.ref('hr.group_hr_manager')
|
group = request.env.ref('hr.group_hr_manager')
|
||||||
users = request.env['res.users'].sudo().search([('groups_id', 'in', group.ids)], order='id')
|
users = request.env['res.users'].sudo().search([
|
||||||
|
('groups_id', 'in', group.ids),
|
||||||
|
('email', '!=', False),
|
||||||
|
('email', '!=', 'hr@ftprotech.com'),
|
||||||
|
('employee_id.department_id.name', '=', 'Human Resource')
|
||||||
|
])
|
||||||
|
|
||||||
|
# Extract emails and join them into a comma-separated string
|
||||||
|
email_cc = ','.join([user.email for user in users])
|
||||||
|
|
||||||
|
# Prepare email values
|
||||||
email_values = {
|
email_values = {
|
||||||
'email_from': applicant.email_from,
|
'email_from': applicant.email_from,
|
||||||
'email_to': 'hr@ftprotech.com',
|
'email_to': 'hr@ftprotech.com',
|
||||||
'email_cc': [user.email for user in users if user.email != 'hr@ftprotech.com' and user.employee_id.department_id.name == 'Human Resource']
|
'email_cc': email_cc
|
||||||
}
|
}
|
||||||
# Use 'with_context' to override the email template fields dynamically
|
|
||||||
template.sudo().send_mail(applicant.id, email_values=email_values,
|
|
||||||
force_send=True)
|
|
||||||
|
|
||||||
return request.render("hr_recruitment_extended.thank_you_template",{
|
# Debug: Print the email_cc value to verify
|
||||||
|
print(f"Email CC value: {email_values['email_cc']}")
|
||||||
|
|
||||||
|
# Send email
|
||||||
|
template.sudo().send_mail(
|
||||||
|
applicant.id,
|
||||||
|
email_values=email_values,
|
||||||
|
force_send=True
|
||||||
|
)
|
||||||
|
|
||||||
|
# Render thank you page
|
||||||
|
return request.render("hr_recruitment_extended.thank_you_template", {
|
||||||
'applicant': applicant
|
'applicant': applicant
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue