跳至內容
選單
此問題已被標幟
1 回覆
4101 瀏覽次數

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
10850
1
9月 24
1503
1
12月 21
3745
2
12月 23
19705
0
3月 15
4117