Odoo Help


Correct a product duplication

on 5/6/13, 5:36 AM 1,510 views

I entered one product 2 times in openerp. For eg suppose i have a product 0000000A-Black But i unknowingly entered 1) 0000000A-Black 2) 0000000A-Blac

and both products have been used in purchase orders means both have receptions. How can i correct this error?

Do you have experience with SQL?

on 5/6/13, 8:49 AM

I have experience in SQL.

on 5/6/13, 9:20 AM

@Remya: I can help someone with SQL experience to solve this. I can also help someone with NO SQL experience to solve this. However the latter is 20 times harder than the former, and the approach would be very different. Are you a colleague of Vardan?

on 5/6/13, 10:26 AM

Yess i have experience in SQL. Please suggest me what to do.

on 5/6/13, 10:58 AM

Were you able to correct the problem?

on 5/9/13, 9:35 AM



| 5 6 8
Cornwall, Canada

Analysing, designing, coding and mentoring since 1975. Kilobytes to terabytes. Punch cards to punchy sites. My OpenERP video series: http://www.youtube.com/playlist?list=PLq7op4J183lX44ZlXPiHxUpRvmmRDtxye My Google Speadsheets --> OpenERP Data Pump project: http://martinhbramwell.github.io/GData_OpenERP_Data_Pump My email (with spaces removed) : mhb . warehouseman @ gmail . com

On 5/6/13, 11:46 AM

(On a copy of the database to begin with!) my approach would be :

  1. Put OpenERP in developer mode
  2. mouse over the relevant fields to get their model and field names
  3. get into the database and query the relevant tables (where model name is product.category the table name would be product_category)
  4. find the record of the product and the records of a 'good' purchase order and a 'bad' one.
  5. examine all the foreign key fields to understand how many need to be changed
  6. try updating the 'bad' purchase order to match the 'good' one where appropriate.
  7. test shipping the goods and receiving payment (on your disposable database copy, of course) to be sure you handled all FK relations correctly.

Feel free to ask further questions in the comment area of this answer.

I will reply with edits to my answer.

Update :

Let's say your "good" and "bad" products look like this.

dbVardan=> select id, name_template from product_product where name_template like '0000000A%';
  id  | name_template  
  202 | 0000000A-Black
  203 | 0000000A-Blac
(2 rows)

So, "good" records, are all those that refer to the product id #202, and "bad" records, are all those that refer to the product id #203.

So with a purchase order like:

dbVardan=> select id, partner_id, name from purchase_order;
 id | partner_id |  name   
 83 |         19 | PO00083
(1 row)

Some of the attributes look like this :

dbVardan=> select id, partner_id, order_id, product_id, name
             from purchase_order_line;
  id  | partner_id | order_id | product_id |      name     
  654 |         19 |       83 |        203 | 0000000A-Blac
(1 row)

To fix, you'd do ...

update purchase_order_line set 
           product_id = 202
         , name = '0000000A-Black'
       where id = 654;

... and up with:

dbVardan=> select id, partner_id, order_id, product_id, name
             from purchase_order_line;
  id  | partner_id | order_id | product_id |      name     
  654 |         19 |       83 |        202 | 0000000A-Black

(1 row)

Obviously, do this on a disposable clone of your database.

To rapidly detect all places where a change might be required:

  1. learn how to make a text file backup of your data base with pg_dump
  2. learn how to use the command diff
  3. save a text snapshot of your database.
  4. with no other users connected or doing anything, run through the complete cycle of: purchase, partial receive, back order, stock move, sell, deliver, AR
  5. save another snapshot of your database
  6. run diff to find every place where that cycle caused update/insert actions to occur.

No, not getting your answer. Are 'good ' and 'bad' stands for 'right' and 'wrong' ? How to examine foreign keys? what to update in 'bad' purchase order?are they not going to affect deliveries and reception?

on 5/9/13, 9:58 AM

I have updated my answer.

on 5/9/13, 3:55 PM

Thanx a lot Martin..very helpful answer..will try it..

on 5/10/13, 4:13 AM

If I have not yet fully answered your question "How can i correct this error?", please let me know what else you would require to know in order to complete it properly.

on 5/10/13, 9:05 AM

i will tell you after i will try this.. thanx a lot buddy..

on 5/10/13, 9:56 AM

No one's saying it'll be easy. ;-(

on 5/10/13, 10:11 AM

yess it is not easy

on 5/10/13, 10:18 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

1 follower(s)


Asked: 5/6/13, 5:36 AM
Seen: 1510 times
Last updated: 3/16/15, 8:10 AM