Files
gzth/attendance_iot/controllers/http.py
T
2025-05-28 16:26:02 +08:00

20 lines
688 B
Python

from odoo.http import JsonRPCDispatcher
class CustomJsonRPCDispatcher(JsonRPCDispatcher):
"""
继承odoo底层源码http.py
因为odoo本身会给对应的接口请求进行自动包装,通过判断做设备区分
"""
def _response(self, result=None, error=None):
if 'api/v1' in self.request.httprequest.headers.environ.get('PATH_INFO'):
return self.request.make_json_response(result)
response = {'jsonrpc': '2.0', 'id': self.request_id}
if error is not None:
response['error'] = error
if result is not None:
response['result'] = result
return self.request.make_json_response(response)