Odoo Help

0

How to execute python-script for importing products directly to postgresql

By
kannu
on 9/3/14, 11:48 AM 7,332 views

I Kept this python file as well as csv file in server-folder. But it's not importing products!

Python Script-

import csv
import psycopg2

conn_string = "dbname= 'toc' user='openerp' password='sigma@123'"

conn = psycopg2.connect(conn_string)
cursor = conn.cursor()

reader = csv.reader(open('prod.csv','rb'))

for row in reader:
    print row[1]
   
    statement = "INSERT INTO product_template (name,description) VALUES ('" +row[1]+"','" +(row[2])+"') RETURNING id"
    
    cursor.execute(statement)
    conn.commit()
    templateid=cursor.fetchone()[0]
       
    statement = "INSERT INTO product_product (product_tmpl_id,default_code,active,valuation) VALUES \
    (" + str(templateid) + ",'" + row[0] + "',True,'manual_periodic')"
   
    cursor.execute(statement)
    conn.commit()
   
   ?
               
   

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: 9/3/14, 11:48 AM
Seen: 7332 times
Last updated: 3/16/15, 8:10 AM