0

I spent more than three hours trying to understand how to create an order using Odoo 11 and Python with no luck.

The smallest example I came to is this:

uid = common.authenticate(db, username, password, {})
models = xmlrpclib.ServerProxy('{}/xmlrpc/2/object'.format(url))

order = models.execute_kw(db, uid, password, 'sale.order', 'create', {
     'name': 'new sale order',
})

But I get:

File "./conexion.py", line 29, in <module>
'name': 'new sale order',
File "/usr/lib/python2.7/xmlrpclib.py", line 1243, in __call__
return self.__send(self.__name, args)
File "/usr/lib/python2.7/xmlrpclib.py", line 1602, in __request
verbose=self.__verbose
File "/usr/lib/python2.7/xmlrpclib.py", line 1283, in request
return self.single_request(host, handler, request_body, verbose)
File "/usr/lib/python2.7/xmlrpclib.py", line 1316, in single_request
return self.parse_response(response)
File "/usr/lib/python2.7/xmlrpclib.py", line 1493, in parse_response
return u.close()
File "/usr/lib/python2.7/xmlrpclib.py", line 800, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 2: ''>

What's wrong with my code?.

Leonardo Ramé
  • 143
  • 1
  • 8

1 Answers1

0

Something late, but someone can be useful. To create an order you need to have the following mandatory fields:

partner_id, pricelist_id and date_order (created by default)

Being that way:

models.execute (dbname, uid, pwd, 'sale.order', 'create', {'partner_id': 1, 'pricelist_id': 1})

This is an answer to your question in odoo forum.

I hope that helps.

Tim Diekmann
  • 7,755
  • 11
  • 41
  • 69