Update: I resolved this issue by setting the values during the import. So there is no urgency. However, I would like to know if I am doing this right.
I am importing leads using a python script. The import itself works great but the fields that get auto filled when I create a lead using the web client remain blank for the leads imported from the script. How do I mimic the auto fill action when importing using an external script. an excerpt from the script is pasted here. The lead shows up correctly in the web client. Just that the other values which get auto filled in the web client are blank. (the code works... it may give errors because it has been heavily redacted.)
import openerplib
import csv
def import_leads(csvfile):
partner_model = connection.get_model('res.partner')
lead_model = connection.get_model('crm.lead')
user_model = connection.get_model('res.users')
with open(csvfile, "rb") as csvfile:
records = csv.reader(csvfile, delimiter=',')
next(records)
for record in records:
print(record[0])
# crmid fields are created in various models
ids = lead_model.search([('crmid', '=', record[0])])
if len(ids) > 0:
continue
ids = partner_model.search([('crmid', '=', record[2])])
if len(ids) is 0:
print("partner not found: " + record[2])
continue
partner_id = ids[0]
from_user = record[19]
ids = user_model.search([('login', '=', from_user)])
from_user_id = ids[0]
lead = {
'crmid': record[0],
'partner_id': partner_id,
'user_id': from_user_id,
'crmid': record[0],
'name': record[4]
}
lead_id = lead_model.create(lead)
# i think i have do something here like browse() or refresh() or something.
hostname = "localhost"
database = "test1"
login = "admin"
password = "admin"
connection = openerplib.get_connection(hostname=hostname,
database=database, login=login, password=password)
import_leads("./Leads.csv")