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

Clean database of undesired products already used by invoice/order

By
NSC
on 8/10/14, 4:06 PM 1,400 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?

1

Ray Carnes

--Ray Carnes--
15677
| 9 7 9
Greater Los Angeles, United States
--Ray Carnes--

Senior Odoo Analyst

OpenERP 6.1, 7.0 and Odoo 8.0, 9.0 (Since 2012)

Completed Functional and Technical Training.

Major Skills:

  • Needs Discovery and Requirements Analysis;

  • Function and Technical Specifications;

  • Project Planning;

  • Prototyping and Proof of concepts;

  • Data migration;

  • Configuration & Customization (UI and modules);

  • Integration - data, business logic and service levels;

  • Training and Knowledge transfer;

  • Go Live support;

  • Help desk;

  • Version Migration.

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. 

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

NSC
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.

Bista Solutions US, 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.

NSC
on 8/12/14, 7:43 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

1 follower(s)

Stats

Asked: 8/10/14, 4:06 PM
Seen: 1400 times
Last updated: 3/16/15, 8:10 AM