I can not connect with odoo in any way, this is what I am doing:
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.
https://freeweblearns.blogspot.com/2018/11/how-to-use-xmlrpc-using-python-for-new.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.