Odoo xml rpc 传递自我

Odoo xml rpc pass self

我需要调用方法 (action_invoice_create) 来记录销售订单。我无法找到如何传递 self 参数。所以任务是为 id = 12 的订单调用方法。这是一些代码:

import xmlrpclib
url = "https://myodoo.com"
db = "mydb"
username = '123'
password = '123'
models = xmlrpclib.ServerProxy('{}/xmlrpc/2/object'.format(url))
new_id = 12  # id of existing sale order
model_name = 'sale.order'
models.execute_kw(db, uid, password, model_name, 'action_invoice_create', [new_id])

你不需要通过self,你必须通过ids
action_invoice_create 期望 ids 作为列表。

common = xmlrpclib.ServerProxy('{}/xmlrpc/2/common'.format(url))
uid = common.authenticate(db, username, password, {})
models.execute_kw(db, uid, password, model_name, 'action_invoice_create', [[new_id]])