JOD EMAIL_cc CHANGE-FIX

This commit is contained in:
pranay 2025-09-15 14:45:35 +05:30
parent 495c27d96d
commit f578cc6cf4
1 changed files with 27 additions and 9 deletions

View File

@ -164,7 +164,6 @@ 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
@ -284,20 +283,39 @@ 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)], 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_from': applicant.email_from,
'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",{
'applicant': applicant
})
# 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
})
def safe_date_parse(self,date_str):
try: