批量发票复制Odoo8

时间:2016-03-14 08:53:46

标签: python xml-rpc odoo-8

无论如何使用xml-rpc复制或创建一堆发票?

我尝试使用Odoo ORMApi的复制方法

invoices = call('account.invoice','search_read', [('type','ilike',"out_invoice")])

for invoice in invoices:
inv = invoice.copy()

如何在数据库中插入新发票?

2 个答案:

答案 0 :(得分:0)

尝试使用erppeek,这是一个让这更容易的python库

client = erppeek.Client(SERVER, DATABASE, USERNAME, PASSWORD)
invoices=client.search('account.invoice',[('type','ilike',"out_invoice")])
for i in range(len(invoices)):
    client.copy('account.invoice',invoices[i-1])

答案 1 :(得分:0)

有许多可用的python rpc客户端,以及erppeek您还可以尝试odoorpcxmlrpclib

以下是使用xmlrpclib的代码段。

import xmlrpclib


domain ='localhost'         #the domain
port=8069                   #the active port
username = 'username'       #the user name
password = 'password'       #the user password 
dbname = 'database_name'    #the database
# # Validate the credentials
url='http://{domain}:{port}'.format(domain=domain,port=port)
login_url='{url}/xmlrpc/2/common'.format(url=url)
sock_common = xmlrpclib.ServerProxy(login_url)
uid = sock_common.login(dbname, username, password)
print sock_common.version()
print uid

models = xmlrpclib.ServerProxy('{}/xmlrpc/2/object'.format(url))


attibute_line = models.execute_kw(dbname, uid, password,
'account.invoice', 'search_read',[[('type','ilike',"out_invoice")]] )

print attibute_line