Pergunta

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

Foi útil?

Solução

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)
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top