Odoo Help


Need help with TypeError: cannot marshal None unless allow_none is enabled

on 5/21/14, 2:10 PM 4,158 views

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
  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()

Jos De Graeve
On 5/22/14, 8:42 AM


You should check the value of cr.fetchall() before returning:

res = cr.fetchall()

if not res:


return res

The xmlrpc spec does not allow to send "None" as a value, that is why you get "Fault cannot marshal None", so you need to send False instead.



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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 5/21/14, 2:10 PM
Seen: 4158 times
Last updated: 3/16/15, 8:10 AM