Skip to Content
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
5998 Представления

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 Ответы Просмотры Активность
2
сент. 23
27778
6
июл. 20
10804
1
мар. 20
3122
5
янв. 20
8832
0
мар. 17
4001