Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
6365 มุมมอง

Hello everyone,

In my module I have a controller type="json", how can I return a json of type {'code': 200} instead of returning an object of type jsonrpc :

{

    "jsonrpc": "2.0",

    "id": null,

    "result": {

        "code": 200,

    }

}

Thanks for all!

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Just edit below portion of the function _json_response defined at odoo/odoo11/odoo/http.py near about line no : 621-630 as below

    def _json_response(self, result=None, error=None):

        response = {
            'jsonrpc': '2.0',
            'id': self.jsonrequest.get('id')
            }
        if error is not None:
            response['error'] = error
        if result is not None:
            response['result'] = result

to new:

    def _json_response(self, result=None, error=None):

        response = {}
        if error is not None:
            response = error
        if result is not None:
            response = result
Please do the procedure at your own risk. these procedure isn't a recommended procedure.
อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Best way to show json data on odoo UI แก้ไขแล้ว
2
ก.ย. 23
28959
6
ก.ค. 20
11550
1
มี.ค. 20
3487
Odoo JSON Filter and Offset Parameter แก้ไขแล้ว
5
ม.ค. 20
9564
0
มี.ค. 17
4432