콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

In which module , can I write controller to fetch hr_employee data. There is no hr_employee module. The data of hr.employee is present across different modules related to hr. 

아바타
취소
베스트 답변

Hi,

Please add the hr module in the dependents list of the manifest file, and after you need to create a controller like


from odoo import http, fields
from odoo.http import request


class ControllerClassName(http.Controller):

@http.route('/route', auth='user', type='json')
def fucntion_name(self):
total_employees = request.env['hr.employee'].search_count(
[('active', '=', True)])
//You can search records based on the given methods and after you can add in the values dict
values = {
'total_employees': total_employees,
}
return {
'html': request.env.ref('module_name.panel_template')._render({
'object': request.env['hr.employee'],
'values': values
})
}
 
// the panel_template I used as a dashboard view, you can render the records in this way

Hope it helps

아바타
취소
관련 게시물 답글 화면 활동
2
4월 22
10968
1
9월 24
1597
1
12월 21
3828
2
12월 23
19842
0
3월 15
4221