这里我列出了一些用于将上下文添加为参数的 xmlrpc(Odoo Web Service API) 常用 ORM 方法的示例语法。
创建
api.execute_kw(db, uid, password, 'res.partner', 'create', [{'name: Atul'}], {'context' :{'tag': 1}})
搜索
api.execute_kw(db, uid, pwd, 'res.partner', 'search_read', [[('name', '=', "Atul")]], {'context' :{'tag': 1}})
搜索阅读
api.execute_kw(db, uid, pwd, 'res.partner', 'search_read', [[('name', '=', "Atul")]], {'fields': ['id', 'name'], 'context' :{'tag': 1}})
阅读
api.execute_kw(db, uid, password, 'res.partner', 'read', [ids], {'context' :{'tag': 1}})
写
api.execute_kw(db, uid, password, 'res.partner', 'write', [[id], {'name': "Atul Arvind"}], {'context' :{'tag': 1}})
取消链接
api.execute_kw(db, uid, password, 'res.partner', 'unlink', [[id]], {'context' :{'tag': 1})
希望这会有所帮助!