Odoo Help

0

Import leads using SQL query but giving error while saving from web form

By
rais
on 3/11/15, 2:02 AM 963 views

Hi Experts,

I have made a python script to import data into leads database, and below is a sample code.

 

sql ="insert into crm_lead(create_uid,write_uid,active,type,color,day_close,day_open,section_id,company_id,priority," \
                    "create_date,write_date,name,street,contact_name,partner_id,city,description,user_id,state,stage_id,planned_revenue,ref2) "\
                                    " values('1','1','1','lead',0,0,0,2,1,3,'%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s',%s,'%s')  " \
                                    "" % (create_date,write_date,location,location,contactname,partner_id,city,notes,user_id,state,stage_id,planned_revenue,quote_id)
                                
                            

cursor.execute(sql)
                            

conn.commit()

It is inserting data into the table without any problem and I can view them in a leads tree view and form views. But when I wanted to make some changes and save in form view it gives following error.

Server Traceback (most recent call last): File "C:\Program Files (x86)\OpenERP7\server\openerp\addons\web\session.py", line 89, in send File "C:\Program Files (x86)\OpenERP7\server\.\openerp\netsvc.py", line 296, in dispatch_rpc File "C:\Program Files (x86)\OpenERP7\server\.\openerp\service\web_services.py", line 626, in dispatch File "C:\Program Files (x86)\OpenERP7\server\.\openerp\osv\osv.py", line 190, in execute_kw File "C:\Program Files (x86)\OpenERP7\server\.\openerp\osv\osv.py", line 132, in wrapper File "C:\Program Files (x86)\OpenERP7\server\.\openerp\osv\osv.py", line 199, in execute File "C:\Program Files (x86)\OpenERP7\server\.\openerp\osv\osv.py", line 187, in execute_cr File "C:\Program Files (x86)\OpenERP7\server\openerp\addons\base_action_rule\base_action_rule.py", line 181, in wrapper File "C:\Program Files (x86)\OpenERP7\server\openerp\addons\crm\crm_lead.py", line 951, in write File "C:\Program Files (x86)\OpenERP7\server\openerp\addons\mail\mail_thread.py", line 297, in write File "C:\Program Files (x86)\OpenERP7\server\.\openerp\osv\orm.py", line 4396, in write File "C:\Program Files (x86)\OpenERP7\server\.\openerp\osv\orm.py", line 4734, in _store_set_values File "C:\Program Files (x86)\OpenERP7\server\.\openerp\osv\fields.py", line 1152, in get File "C:\Program Files (x86)\OpenERP7\server\openerp\addons\crm\crm_lead.py", line 197, in _compute_day File "C:\Program Files (x86)\OpenERP7\server\.\openerp\osv\orm.py", line 503, in __getattr__ File "C:\Program Files (x86)\OpenERP7\server\.\openerp\osv\orm.py", line 481, in __getitem__ ValueError: need more than 1 value to unpack

 

I am new to openerp and not sure I am following the correct way to import data. But, also I tried to import data using csv in leads and it does not give such error. Is it some dependancy in leads like message, followers, etc that I am missing here. Your guide much appreciated. Thanks in advance.

 

Whats is the create date in your db after the commit ? The problem seems to be when orm try to get create_date from the lead ! Anyways, it's always better to use the import csv to respect the workflow, default values, computed field and co... So why not update your python script to generate csv file, or use xml_rpc to insert your data ? Good luck

Jérémy Kersten (jke)
on 3/11/15, 5:41 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 3/11/15, 2:02 AM
Seen: 963 times
Last updated: 3/16/15, 8:10 AM