Files
gzth/yuthon_hr_employee/controllers/employee_banner_route.py
T
2026-05-30 13:10:02 +08:00

30 lines
1.4 KiB
Python

from odoo.http import Controller, request, route
class EmployeeBannerRoute(Controller):
@route('/employee/banner/route', type='json', auth='user')
def employee_banner_route(self, **kwargs):
employees = request.env['hr.employee'].sudo()
hired_count = employees.search_count([('use_user_type', '=', 'formal_one')]) # 正式
in_hired_count = employees.search_count([]) # 在职
all_hired_count = employees.search_count([]) # 全职
return {
# 'html': f"""
# <div style="display: flex; justify-content: space-around; align-items: center; text-align: center; padding: 20px; width: 100%;margin-top:25px;margin-bottom:25px;">
# <div style="flex: 1; padding: 20px;">
# <h2>正式</h2>
# <p style="font-size: 24px; color: #4CAF50;">{hired_count}</p>
# </div>
# <div style="flex: 1; padding: 20px;">
# <h2>在职</h2>
# <p style="font-size: 24px; color: #2196F3;">{in_hired_count}</p>
# </div>
# <div style="flex: 1; padding: 20px;">
# <h2>全职</h2>
# <p style="font-size: 24px; color: #FF5722;">{all_hired_count}</p>
# </div>
# </div>
# """
}