Initial commit on branch odoo_DuyDat
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
from odoo import http
|
||||
from odoo.http import request
|
||||
import json
|
||||
|
||||
class EmployeeController(http.Controller):
|
||||
|
||||
@http.route('/employees', type='http', auth='none', methods=['GET'], csrf=False)
|
||||
def get_employees(self, **kwargs):
|
||||
employees = request.env['employee.profile'].sudo().search([])
|
||||
|
||||
result = []
|
||||
for emp in employees:
|
||||
result.append({
|
||||
'id': emp.id,
|
||||
'name': emp.name,
|
||||
'email': emp.email,
|
||||
'phone': emp.phone,
|
||||
'position': emp.position,
|
||||
})
|
||||
|
||||
# Trả về JSON response
|
||||
return http.Response(
|
||||
json.dumps({'status': 'success', 'employees': result}),
|
||||
content_type='application/json',
|
||||
status=200
|
||||
)
|
||||
Reference in New Issue
Block a user