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
สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!
สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!
ลงชื่อ| Related Posts | ตอบกลับ | มุมมอง | กิจกรรม | |
|---|---|---|---|---|
|
|
2
เม.ย. 22
|
13183 | ||
|
|
1
ก.ย. 24
|
3293 | ||
|
|
1
ธ.ค. 21
|
5424 | ||
|
|
2
ธ.ค. 23
|
22256 | ||
|
|
0
มี.ค. 15
|
5572 |