65 lines
2.6 KiB
Python
65 lines
2.6 KiB
Python
from odoo import http, _
|
|
from odoo.http import request
|
|
from odoo.addons.hr_recruitment_extended.controllers.controllers import website_hr_recruitment_applications
|
|
from odoo.http import content_disposition
|
|
|
|
import logging
|
|
|
|
from odoo18.odoo.tools import misc
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
class website_hr_recruitment_applications_extended(website_hr_recruitment_applications):
|
|
|
|
@http.route(['/FTPROTECH/JoiningForm/<int:applicant_id>'], type='http', auth="public",
|
|
website=True)
|
|
def post_onboarding_form(self, applicant_id, **kwargs):
|
|
"""Renders the website form for applicants to submit additional details."""
|
|
applicant = request.env['hr.applicant'].sudo().browse(applicant_id)
|
|
if not applicant.exists():
|
|
return request.not_found()
|
|
if applicant and applicant.send_post_onboarding_form:
|
|
if applicant.post_onboarding_form_status == 'done':
|
|
return request.render("hr_recruitment_extended.thank_you_template", {
|
|
'applicant': applicant
|
|
})
|
|
else:
|
|
return request.render("hr_recruitment_extended.post_onboarding_form_template", {
|
|
'applicant': applicant
|
|
})
|
|
else:
|
|
return request.not_found()
|
|
|
|
@http.route(['/download/jod/<int:applicant_id>'], type='http', auth="public", cors='*', website=True)
|
|
def download_jod_form(self, applicant_id, **kwargs):
|
|
# Get the applicant record
|
|
applicant = request.env['hr.applicant'].sudo().browse(applicant_id)
|
|
if not applicant.exists():
|
|
return f"Error: Applicant with ID {applicant_id} not found"
|
|
|
|
# Business logic check
|
|
if not applicant.send_post_onboarding_form or applicant.post_onboarding_form_status != 'done':
|
|
return f"Error: Applicant {applicant_id} does not meet the criteria for download"
|
|
|
|
# Get the template
|
|
template = request.env.ref('hr_recruitment_extended.employee_joining_form_template')
|
|
if not template:
|
|
return "Error: Template not found"
|
|
|
|
try:
|
|
# Render the template to HTML for debugging
|
|
html = request.env['ir.qweb']._render(
|
|
template.id,
|
|
{
|
|
'docs': applicant,
|
|
'doc': applicant,
|
|
'time': misc.datetime,
|
|
'user': request.env.user,
|
|
}
|
|
)
|
|
|
|
# Return HTML for debugging
|
|
return html
|
|
|
|
except Exception as e:
|
|
return f"Error rendering template: {str(e)}" |