Openerp Odoo JSONRPC服务(http.route type=json)不工作

Openerp Odoo JSONRPC服务(http.route type=json)不工作,openerp,odoo-8,json-rpc,Openerp,Odoo 8,Json Rpc,我正在尝试在odoo中创建jsonrpc服务。当我使用doc创建clean模块并添加这样的代码时 **[controllers.py]** @http.route(['/my_academy/ret/'], type='json', auth="public") def change_size(self): return {'x': 1, 'y': 2} **[controllers.py]** @http.route(['/academy/jsonrpc/'], ty

我正在尝试在odoo中创建jsonrpc服务。当我使用doc创建clean模块并添加这样的代码时

**[controllers.py]**
@http.route(['/my_academy/ret/'], type='json', auth="public")
    def change_size(self):
        return {'x': 1, 'y': 2}
**[controllers.py]**
@http.route(['/academy/jsonrpc/'], type='json', auth="public")
    def return_map(self):
        return {'x': 12345, 'y': 2222}
尝试从js连接:

    "use strict";
    var requestUrl = '/my_academy/ret/';

    openerp.jsonRpc(requestUrl, 'call', {})
        .then(function (data) {
            alert(data['x']);
        });
一切正常。我收到消息“1”。 当我使用doc创建模块并添加这样的代码时

**[controllers.py]**
@http.route(['/my_academy/ret/'], type='json', auth="public")
    def change_size(self):
        return {'x': 1, 'y': 2}
**[controllers.py]**
@http.route(['/academy/jsonrpc/'], type='json', auth="public")
    def return_map(self):
        return {'x': 12345, 'y': 2222}
修改js并尝试连接

    "use strict";
    var requestUrl = '/academy/jsonrpc/';

    openerp.jsonRpc(requestUrl, 'call', {})
        .then(function (data) {
            alert(data['x']);
        });
我收到错误消息

code: 200
data: Object
    arguments: Array[0]
        length: 0
        __proto__: Array[0]
        ....
    debug: "Traceback (most recent call last):↵  
            File "/home/skif/odoo/openerp/http.py", line 539, in _handle_exception↵    
            return super(JsonRequest, self)._handle_exception(exception)↵
            File "/home/skif/odoo/openerp/addons/base/ir/ir_http.py", line 152, in _dispatch↵    
            rule, arguments = self._find_handler(return_rule=True)↵  
            File "/home/skif/odoo/openerp/addons/base/ir/ir_http.py", line 65, in _find_handler↵    
            return self.routing_map().bind_to_environ(request.httprequest.environ).match(return_rule=return_rule)↵  
            File "/usr/local/lib/python2.7/dist-packages/werkzeug/routing.py", line 1430, in match↵    
            raise NotFound()↵
            NotFound: 404: Not Found↵"
    message: ""
    name: "werkzeug.exceptions.NotFound"
    __proto__: Object

message: "Odoo Server Error"
__proto__:Object
我做错了什么?为什么我不能使用类似的代码?

请尝试以下代码:

@http.route(['/academy/jsonrpc'], type='json', auth="public", website=True)
def return_map(self, **post):
    return {'x': 12345, 'y': 2222}
这可能对您的情况有所帮助。

请尝试以下代码:

@http.route(['/academy/jsonrpc'], type='json', auth="public", website=True)
def return_map(self, **post):
    return {'x': 12345, 'y': 2222}

这可能对您的情况有所帮助。

您是否在init中导入了控制器。pyI尝试使用auth=“none”-nothing。如果模块开发的网站,然后所有的工作良好。如果模块开发的后端,如我有问题。我是否需要声明任何模块或安全参数?是的,我需要。#--编码:utf-8——导入控制器从导入模型#相互点击。导入伙伴这是代码工作正常@http.route('/academy/academy/',auth='public',website=True)def index(self,**kw):返回http.request.render('academy.index',{'message':[“Hello World”,“Hi all!”]),但这不是Json:(您在init.py中导入了控制器吗?我尝试使用auth=“none”-什么都没有。如果为网站开发模块,那么一切都正常。如果为后端开发模块,比如我有问题。我可能需要声明任何模块或安全参数吗?是的,我有。#--编码:utf-8--导入控制器导入模型#interhits from.import partners这是code work fine@http.route('/academy/academy/',auth='public',website=True)def index(self,**kw):返回http.request.render('academy.index',{'message':[“Hello World”,“Hi all!”]),但这不是Json:(