63 lines
2.3 KiB
Python
63 lines
2.3 KiB
Python
|
|
import warnings
|
|
from datetime import datetime
|
|
from dateutil.relativedelta import relativedelta
|
|
from operator import itemgetter
|
|
from werkzeug.urls import url_encode
|
|
|
|
from odoo import http, _, fields
|
|
from odoo.addons.website_hr_recruitment.controllers.main import WebsiteHrRecruitment
|
|
from odoo.osv.expression import AND
|
|
from odoo.http import request
|
|
from datetime import timedelta
|
|
from odoo.tools import email_normalize
|
|
from odoo.tools.misc import groupby
|
|
import base64
|
|
from odoo.exceptions import UserError
|
|
|
|
from PIL import Image
|
|
from io import BytesIO
|
|
import re
|
|
import json
|
|
|
|
|
|
|
|
class website_hr_recruitment_applications(http.Controller):
|
|
|
|
@http.route('/recruitment/get_assignees', type='json', auth='user', methods=['POST'])
|
|
def get_assignees(self):
|
|
"""Fetch users who are in the 'Recruitment Interview Group'."""
|
|
group_id = request.env.ref("hr_recruitment.group_hr_recruitment_interviewer").id
|
|
assignees = request.env["res.users"].sudo().search([
|
|
("groups_id", "in", [group_id])
|
|
])
|
|
|
|
return [{"id": int(user.id), "name": user.name} for user in assignees]
|
|
|
|
@http.route('/custom_dashboard/recruitment_data', type='json', auth='user')
|
|
def recruitment_data(self, params=None):
|
|
domain = []
|
|
if params:
|
|
if params.get('date_range'):
|
|
date_range = params['date_range']
|
|
# Apply the date range filter in the domain
|
|
if date_range == "7":
|
|
domain.append(('create_date', '>=', fields.Date.today() - timedelta(days=7)))
|
|
elif date_range == "30":
|
|
domain.append(('create_date', '>=', fields.Date.today() - timedelta(days=30)))
|
|
# Add more conditions for different date ranges
|
|
|
|
if params.get('assignees'):
|
|
domain.append(('user_id', 'in', params['assignees']))
|
|
|
|
# Fetch data based on filtered domain
|
|
total_open_positions = request.env['hr.job.recruitment'].search_count(domain)
|
|
total_applications = request.env['hr.applicant'].search_count(domain)
|
|
# active_jobs = request.env['hr.job'].search_count(domain + [('state', '=', 'open')])
|
|
|
|
return {
|
|
'total_open_positions': total_open_positions,
|
|
'total_applications': total_applications,
|
|
'active_jobs': 52,
|
|
}
|