Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
I have a php application that connect to a 6.0 version of OpenERP using netrpc. I'm now trying to check if I can use the same code to connect my application to a 7.0 version. After analysing the code, I found that it's based on socket communications, so I prepared this code to make somme tests:
msg = ('common', 'login', 'db_name', 'admin', 'secret')
msg = cPickle.dumps([msg,None])
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print sock.connect_ex(('localhost', 8070))
sock.sendall('%8d%s%s' % (len(msg), True and "1" or "0", msg))
#print sock.recv(8 - len(buf))
def read(socket, size):
while len(buf) < size:
chunk = socket.recv(size - len(buf))
print "cunk ", chunk
if chunk == '':
raise RuntimeError, "socket connection broken"
buf += chunk
except Exception, e:
size = int(read(sock, 8))
buf = read(sock, 1)
exception = buf != '0' and buf or False
res = cPickle.loads(read(sock, size))
raise TinySocketError(ustr(res), ustr(res))
print "res ",res
When I run this code whyle a 6.0 server is running, I got an answer. But with a 7.0 server running, I have a Timeout problem (and I see openerp.service.netrpc_server: starting NET-RPC service on 0.0.0.0:8070 in the log so the netrpc service must be running). So I digged a litte in the OpenERP net-rpc code, and I found that the netrpc server is runned via the netrcp_server.py. After that I discovered that the difference between 6.0 and 7.0 is that in the first one, the function TinySocketServerThread.run was called, but in the second, it wasn't, witch means (If I'm not wrong) that there was no client socket waiting for connection witch explain why I don't get an answer.
So, is there anything wrong with my analysis? Did someone tested to use net rpc with a 7.0 of openerp? Did I miss something to make the netrpc work properly?
After more checking I found this: in the 6.0 version, the netrpc and other service are runned by calling
In openerp-server.py. In 7.0 version, this function is not called nowere, so I added :
In the __init__.py under the service folder in the end of the start_services function : after that, the thread was lunched and I can see that the server did receive the socket call. But I found another problem: in TinySocketClientThread.run function, this line
ts = openerp.server.netrpc_socket.mysocket(self.sock)
must be replaced by this one
ts = openerp.service.netrpc_socket.mysocket(self.sock)
After that, it worked fine.
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 8/28/14, 6:33 AM|
|Seen: 1074 times|
|Last updated: 3/16/15, 8:10 AM|