简体   繁体   English

与odoo xmlrpc连接时的Django错误

[英]django error when connecting with odoo xmlrpc

I can not connect with odoo in any way, this is what I am doing: 我无法以任何方式连接到odoo,这就是我正在做的事情:

view.py view.py

class UserSerializer(ModelSerializer):
    class Meta:
        model = User
        fields = '__all__'

class ProxiedTransport(Transport):

    def set_proxy(self, host, port=None, headers=None):
        self.proxy = host, port
        self.proxy_headers = headers

    def make_connection(self, host):
        connection = http.client.HTTPConnection(*self.proxy)
        connection.set_tunnel(host, headers=self.proxy_headers)
        self._connection = host, connection
        return connection

class ResUser(ViewSet):
    url = 'http://localhost'
    db = 'odoo8'
    username = 'admin'
    password = 'admin'

    def list(self,request,format=None):
        p = ProxiedTransport()
        p.set_proxy('proxy.server',8080)
        common = ServerProxy('{}/xmlrpc/2/common'.format(self.url),p)
        uid = common.authenticate(self.db,self.username,self.password,{})

        return Response({})

But he throws me an error: 但是他给我丢了一个错误:

Request Method:     GET 
Request URL:    http://localhost:8000/odoo-api/res/
Django Version:     2.1 
Exception Type:     gaierror 
Exception Value:    [Errno -2] Name or service not known
Exception Location:     /usr/lib/python3.6/socket.py in getaddrinfo, line 745

Where can be the problem? 问题出在哪里?

In url variable you need to add port number along with column sign for more information please check below example in python. url变量中,您需要添加端口号和列符号以获取更多信息,请在python中检查以下示例。

https://freeweblearns.blogspot.com/2018/11/how-to-use-xmlrpc-using-python-for-new.html https://freeweblearns.blogspot.com/2018/11/how-to-use-xmlrpc-using-python-for-new.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM