我花了三个多小时试图了解如何使用Odoo 11和Python创建订单而没有运气。
我遇到的最小例子是:
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',
})
但我明白了:
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: ''>
我的代码出了什么问题?。
答案 0 :(得分:0)
迟到了,但有人可能会有用。要创建订单,您需要具有以下必填字段:
partner_id, pricelist_id and date_order (created by default)
这样:
models.execute (dbname, uid, pwd, 'sale.order', 'create', {'partner_id': 1, 'pricelist_id': 1})
This is an answer在odoo论坛上提问。
我希望有所帮助。