Odoo Help

Welcome!

This community 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.

0

What causes - Integrity Error - duplicate key value

By
john
on 3/4/13, 1:04 PM 1,893 views

when i try and save a new product i get an Integrity Error : duplicate key value violates unique constraint "product_template_pkey"

this is after importing some products to the DB via SQL to tables poduct_template and product_product.

i dont have any repeated primary key id values in the first column of either table.

where should i be looking for the fault ?

// Login to psql and run the following
// What is the result?
SELECT MAX(id) FROM your_table;

// Then run...
// This should be higher than the last result.
SELECT nextval('your_table_id_seq');

// If it's not higher... run this set the sequence last to your highest pid it. 
// (wise to run a quick pg_dump first...)
SELECT setval('your_table_id_seq', (SELECT MAX(id) FROM your_table));
john
on 3/6/13, 4:34 PM

Google: 'Sequence-Manipulation Functions'... Using pgAdmin you can view SEQUENCE information via a dialogue box and update the sequence value to equal the next desired record ID.

john
on 3/8/13, 11:11 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 3/4/13, 1:04 PM
Seen: 1893 times
Last updated: 3/16/15, 8:10 AM