Hello, I am trying to make an rpc call to the server which returns a set of data. When I run my code I get this error:
Traceback (most recent call last):
File "C:\Python27\Examples\customer_regreq_end_user.py", line 15, in <module>
end_users = sock.execute('TestServerDB', uid, 'mds123', 'res.partner.end.user', 'get_partner_end_users')
File "C:\Python27\lib\xmlrpclib.py", line 1224, in __call__
return self.__send(self.__name, args)
File "C:\Python27\lib\xmlrpclib.py", line 1578, in __request
verbose=self.__verbose
File "C:\Python27\lib\xmlrpclib.py", line 1264, in request
return self.single_request(host, handler, request_body, verbose)
File "C:\Python27\lib\xmlrpclib.py", line 1297, in single_request
return self.parse_response(response)
File "C:\Python27\lib\xmlrpclib.py", line 1473, in parse_response
return u.close()
File "C:\Python27\lib\xmlrpclib.py", line 793, in close
raise Fault(**self._stack[0])
Fault: <Fault cannot marshal None unless allow_none is enabled: 'Traceback (most recent call last):\n File "C:\\Program Files (x86)\\OpenERP 7.0-20130722-231026\\Server\\server\\.\\openerp\\service\\wsgi_server.py", line 83, in xmlrpc_return\n File "xmlrpclib.pyc", line 1132, in dumps\n File "xmlrpclib.pyc", line 677, in dumps\n File "xmlrpclib.pyc", line 699, in __dump\n File "xmlrpclib.pyc", line 759, in dump_array\n File "xmlrpclib.pyc", line 699, in __dump\n File "xmlrpclib.pyc", line 759, in dump_array\n File "xmlrpclib.pyc", line 699, in __dump\n File "xmlrpclib.pyc", line 703, in dump_nil\nTypeError: cannot marshal None unless allow_none is enabled\n'>
Here is the script that calls the method:
import xmlrpclib
# Get the uid
sock_common = xmlrpclib.ServerProxy ('http://localhost:8069/xmlrpc/common')
uid = sock_common.login('DB', 'admin', 'password')
#replace localhost with the address of the server
sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/object')
end_users = sock.execute('DB', uid, 'password', 'res.partner.end.user', 'get_partner_end_users')
this is the method that is called:
def get_partner_end_users(self, cr, uid, context=None):
# Summary:
# The end users are related to a partner_id
# The user logging into the system will have a user_id and a partner_id
# We need to look up the users record, then get the partner_id in order to find the end users
# 1. Look up the user's record from res.users and find the partner_id value
users_partner_id = self.pool.get('res.users').browse(cr, uid, uid).partner_id.id
# 2. Use the partner_id to search for all related end users
cr.execute('Select * from res_partner_end_user where partner_id = %d' % users_partner_id)
# 3. Return the data set
return cr.fetchall()