跳至内容
菜单
此问题已终结

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
10687
1
9月 24
1379
1
12月 21
3648
2
12月 23
19526
0
3月 15
3988