how to pass many2one object in xmlrpc for openerp

隐身守侯 提交于 2019-12-11 22:30:21

问题


I have django as front-end app, where I am saving "res.partner" id relating to django user. Based on that id I am fetching "res.partner" object from openerp. Now I want pass that "res.partner" object to openerp field having many2one relation, using xmlrpc. All other fields along with this object is being saved but not this object. Can you please guide me how to pass object in xmlrpc for openerp


回答1:


You need to pass id value (db id field) to the field(many2one).

Please check documentation here

In the doucmentation you can see partner_id is created and the id field is returned there

import xmlrpclib

sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/object')
uid = 1
pwd = 'demo'

partner = {
    'title': 'Monsieur',
    'name': 'Fabien Pinckaers',
    'lang': 'fr',
    'active': True,
}

partner_id = sock.execute(dbname, uid, pwd, 'res.partner', 'create', partner)

address = {
    'partner_id': partner_id,
    'type': 'default',
    'street': 'Rue du vieux chateau, 21',
    'zip': '1457',
    'city': 'Walhain',
    'phone': '(+32)10.68.94.39',
    'fax': '(+32)10.68.94.39',
}

sock.execute(dbname, uid, pwd, 'res.partner.address', 'create', address)


来源:https://stackoverflow.com/questions/23520584/how-to-pass-many2one-object-in-xmlrpc-for-openerp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!