gpt4 book ai didi

xml-rpc - Odoo 10 - 从 XMLRPC 调用方法

转载 作者:行者123 更新时间:2023-12-05 00:13:33 24 4
gpt4 key购买 nike

我有扩展模型 stock.picking使用名为 do_new_transfer_xmlrpc 的新方法它启用了来自 XMLRPC 的基本 new_transfer。

class Picking(models.Model):
_inherit = 'stock.picking'

@api.multi
def do_new_transfer_xmlrpc(self):
print 'DEBUG'
self.do_transfer()
return ['OK', '']

我尝试使用以下方法调用该方法:
api.execute_kw(db, uid, pwd, 'stock.picking', 'do_new_transfer_xmlrpc', [[int(picking_id)], {}])

但我得到:
Fault: <Fault 1: 'Traceback (most recent call last):\n  File "/usr/lib/python2.7/dist-packages/odoo/service/wsgi_server.py", line 56, in xmlrpc_return\n    result = odoo.http.dispatch_rpc(service, method, params)\n  File "/usr/lib/python2.7/dist-packages/odoo/http.py", line 118, in dispatch_rpc\n    result = dispatch(method, params)\n  File "/usr/lib/python2.7/dist-packages/odoo/service/model.py", line 38, in dispatch\n    res = fn(db, uid, *params)\n  File "/usr/lib/python2.7/dist-packages/odoo/service/model.py", line 157, in execute_kw\n    return execute(db, uid, obj, method, *args, **kw or {})\n  File "/usr/lib/python2.7/dist-packages/odoo/service/model.py", line 101, in wrapper\n    return f(dbname, *args, **kwargs)\n  File "/usr/lib/python2.7/dist-packages/odoo/service/model.py", line 164, in execute\n    res = execute_cr(cr, uid, obj, method, *args, **kw)\n  File "/usr/lib/python2.7/dist-packages/odoo/service/model.py", line 153, in execute_cr\n    return odoo.api.call_kw(recs, method, args, kw)\n  File "/usr/lib/python2.7/dist-packages/odoo/api.py", line 685, in call_kw\n    method = getattr(type(model), name)\nAttributeError: type object \'stock.picking\' has no attribute \'do_new_transfer_xmlrpc\'\n'>

使用的调用方法是否正确编写?

最佳答案

这是正确的语法:

api.execute_kw(db, uid, pwd, 'stock.picking', 'do_new_transfer_xmlrpc', [int(picking_id)])

关于xml-rpc - Odoo 10 - 从 XMLRPC 调用方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48434971/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com