当前位置 : 主页 > 网页制作 > xml >

xml-rpc – Odoo 10 – 来自XMLRPC的调用方法

来源:互联网 收集:自由互联 发布时间:2021-06-13
我扩展了模型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 '
我扩展了模型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)])
网友评论