Compare commits

..

No commits in common. "45fe2f932dc01785e9f220d49a7c22a5a61fa64a" and "f81117d63cb1eed7be0fa1086433e9ba787610c2" have entirely different histories.

1 changed files with 9 additions and 27 deletions

View File

@ -164,6 +164,7 @@ class website_hr_recruitment_applications(http.Controller):
@http.route(['/FTPROTECH/submit/<int:applicant_id>/JoinForm'], type='http', auth="public",
methods=['POST'], website=True, csrf=False)
def process_employee_joining_form(self,applicant_id,**post):
applicant = request.env['hr.applicant'].sudo().browse(applicant_id)
if not applicant.exists():
return request.not_found() # Return 404 if applicant doesn't exist
@ -283,39 +284,20 @@ class website_hr_recruitment_applications(http.Controller):
applicant.write(applicant_data)
template = request.env.ref('hr_recruitment_extended.email_template_post_onboarding_form_user_submit',
raise_if_not_found=False)
# Get HR managers with HR department
group = request.env.ref('hr.group_hr_manager')
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
users = request.env['res.users'].sudo().search([('groups_id', 'in', group.ids)], order='id')
email_values = {
'email_from': applicant.email_from,
'email_to': 'hr@ftprotech.com',
'email_cc': email_cc
'email_cc': [user.email for user in users if user.email != 'hr@ftprotech.com' and user.employee_id.department_id.name == 'Human Resource']
}
# Use 'with_context' to override the email template fields dynamically
template.sudo().send_mail(applicant.id, email_values=email_values,
force_send=True)
# 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
})
return request.render("hr_recruitment_extended.thank_you_template",{
'applicant': applicant
})
def safe_date_parse(self,date_str):
try: