This question has been flagged
1 Reply
2908 Views

Hello! I am using Odoo 9 webservice, to create leads using Python. Everything works fine, but I have a small problem. When I want to pass the field 'user_id', I get the following error: (u "The loss in the database of ids (\ '1 \') and the presence of extra ids (1), can be caused for some \ \ xfan type of inconsistency in a previous query. ", None) '>.

Send leads with the fields 'partner_id' and 'team_id', and they worked fine. I know they are not the same, but I wanted to try. Does someone go through a similar case or can you help me? Thank you.


Script:

import xmlrpclib

db = '999PRU'
username = 'username'
password = 'password123'
url = ''

common = xmlrpclib.ServerProxy('{}/xmlrpc/2/common'.format(url))
uid = common.authenticate(db, username, password, {})

models = xmlrpclib.ServerProxy('{}/xmlrpc/2/object'.format(url))

id = models.execute_kw(db, uid, password, 'crm.lead', 'create', [{
'name': 'Santiago',
'email_from': 'santi_0898@me.com',
'phone': '',
'user_id': '1'

}])

print id
Avatar
Discard
Best Answer
id = models.execute_kw(db, uid, password, 'crm.lead', 'create', [{
'name': 'Santiago',
'email_from': 'santi_0898@me.com',
'phone': '',
'user_id': '1'

}])


User_id field is many2one filed which stores id of the related record , the ids are stored as interger values not string ('1') values , you should send the only 1 to add record id i to user_id field

try this 

id = models.execute_kw(db, uid, password, 'crm.lead', 'create', [{
'name': 'Santiago',
'email_from': 'santi_0898@me.com',
'phone': '',
'user_id': 1

}])
Avatar
Discard