Odoo Help


What causes - Integrity Error - duplicate key value

on 3/4/13, 1:04 PM 2,687 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));
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.

on 3/8/13, 11:11 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.


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

0 follower(s)


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