Odoo Help


Clean database of undesired products already used by invoice/order

on 8/10/14, 4:06 PM 2,022 views

I want to manually clean my database (Odoo V7). Reason: There are some products, I want to get rid of and deleting products is impossible via UI if they are used at least one time. Therefore, I would like to interchange product_id of account_invoice_line with another one. My problem is, that I do not know what are the dependencies to other tables when doing that.

What I have just tried, is do do:

alter table account_invoice_line disable trigger all
update account_invoice_line set product_id = 100 where product_id = 2

I am familiar with SQL, that is not problem - but I do not know if this change is enough as I can estimate the dependencies to other models. Could anybody guide me in clearing my database of undesired products already used?


Ray Carnes

--Ray Carnes--
| 9 7 9
Keyport, United States
--Ray Carnes--

Senior ERP Analyst

OpenERP 6.1, 7.0; Odoo 8.0, 9.0, 10.0 and 11.0.

Completed Odoo Functional and Technical Training.

Functional Areas:

  • CRM/Sales

  • Inventory

  • Manufacturing

  • Accounting

  • Purchasing

Major Skills:

  • Business Process Reengineering

  • Efficiency Consulting

  • User Needs and GAP Analysis;

  • Functional and Technical Design;

  • Prototyping and Proof of Concepts;

  • Requirements Specifications;

  • Agile Implementation;

  • Data Migration;

  • Configuration & Customization (UI and code);

  • Integration - Odoo and non Odoo Applications and Services;

  • Training and Knowledge Transfer;

  • Go Live Support;

  • Helpdesk;

  • Version Upgrades and Migration.

  • Accounting Expert.

I have over 20 years of experience empowering and enabling users with enterprise information systems that make a real and measurable difference in their ability to proactively manage their businesses and organizations. 

I am a skilled Communicator and I only take the serious things seriously!

Ray Carnes
On 8/10/14, 5:15 PM

Have you seen https://www.odoo.com/apps/7.0/object_merger/ - you can create the product you want, select anything you want to have merged into it and the module will correctly navigate through every part of the system, essentially finding all of the old product and replacing them with the new product.


Oh, I did not know about this! Sounds nice! Thank you! My problem is, that for example, one and the same product was generated twice and both of them are used either by invoices or by orders. So I changed assertion of product_id via database in account_invoice_line or purchase_order_line like described above (with reenabling constraints in the end, of course!). Seems to work... We only have some orders, invoices and account_vouchers as well as their bookings in our system - up to now, nothing else. And we do not use any special modules, only standard things. Ray, do you know, if I will get any side effects with my approach? Because I have already finished it and I believe, my database is clean now. If I risked any side effects, I would redo it using your approach (of course, I have a backup of the state before), but if the module suggested by you (I did not know the existence of) did exactly the same automatically without the necessity of database knowledge as I did manually, I would leave it like it is now...

on 8/11/14, 2:12 AM

There are other tables where you may need to change the ID - some of these are: account_move_line, mrp_bom, mrp_production, mrp_production_product_line, mrp_workcenter, procurement_order, product_packaging, product_pricelist_item, sale_order_line, stock_inventory_line, stock_move.

Ray Carnes
on 8/11/14, 7:17 PM

Okay, you have just convinced me to take the most secure way... Anyway, this is still not a big deal, because since my manual database patchings, nobody has made any changes in the system so far... So I installed ObjectMerger into my backup from before my manual patchings. It seems, that it did his job. Therefore, I will mark your solution as accepted and thank you another time for this hint. But I would still need one recommendation: ObjectMerger is a community module. The use of community modules can possibly be ... let's say ... a bit dangerous in production systems (incompatibility with system upgrades etc.). Would you therefore consider to uninstall it after having finished using it so far and reinstall it on demand? If there will be any incompatibilities in future, we won't get in trouble with our database, because in this case, it will not install, and in every case, such tests are always done in mirror databases. I think, this is the most secure way. What do you think about it? In every case, the source code of this module is really useful as it reveals which models/tables to touch when doing such database cleanings manually.

on 8/12/14, 7:43 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: 8/10/14, 4:06 PM
Seen: 2022 times
Last updated: 3/16/15, 8:10 AM