Browse Source
[CHG] Migration to 8.0
[CHG] database_cleanup: move description to README.rst
pull/1009/head
Anthony Muschang
10 years ago
committed by
Holger Brunn
No known key found for this signature in database
GPG Key ID: 1C9760FECA3AE18
3 changed files with
23 additions and
18 deletions
-
database_cleanup/README.rst
-
database_cleanup/__openerp__.py
-
database_cleanup/model/purge_models.py
|
|
@ -0,0 +1,15 @@ |
|
|
|
Clean your OpenERP database from remnants of modules, models, columns and |
|
|
|
tables left by uninstalled modules (prior to 7.0) or a homebrew database |
|
|
|
upgrade to a new major version of OpenERP. |
|
|
|
|
|
|
|
After installation of this module, go to the Settings menu -> Technical -> |
|
|
|
Database cleanup. Go through the modules, models, columns and tables |
|
|
|
entries under this menu (in that order) and find out if there is orphaned data |
|
|
|
in your database. You can either delete entries by line, or sweep all entries |
|
|
|
in one big step (if you are *really* confident). |
|
|
|
|
|
|
|
Caution! This module is potentially harmful and can *easily* destroy the |
|
|
|
integrity of your data. Do not use if you are not entirely comfortable |
|
|
|
with the technical details of the OpenERP data model of *all* the modules |
|
|
|
that have ever been installed on your database, and do not purge any module, |
|
|
|
model, column or table if you do not know exactly what you are doing. |
|
|
@ -34,22 +34,4 @@ |
|
|
|
'view/purge_data.xml', |
|
|
|
'view/menu.xml', |
|
|
|
], |
|
|
|
'description': """\ |
|
|
|
Clean your OpenERP database from remnants of modules, models, columns and |
|
|
|
tables left by uninstalled modules (prior to 7.0) or a homebrew database |
|
|
|
upgrade to a new major version of OpenERP. |
|
|
|
|
|
|
|
After installation of this module, go to the Settings menu -> Technical -> |
|
|
|
Database cleanup. Go through the modules, models, columns and tables |
|
|
|
entries under this menu (in that order) and find out if there is orphaned data |
|
|
|
in your database. You can either delete entries by line, or sweep all entries |
|
|
|
in one big step (if you are *really* confident). |
|
|
|
|
|
|
|
Caution! This module is potentially harmful and can *easily* destroy the |
|
|
|
integrity of your data. Do not use if you are not entirely comfortable |
|
|
|
with the technical details of the OpenERP data model of *all* the modules |
|
|
|
that have ever been installed on your database, and do not purge any module, |
|
|
|
model, column or table if you do not know exactly what you are doing. |
|
|
|
""", |
|
|
|
|
|
|
|
} |
|
|
@ -52,6 +52,7 @@ class CleanupPurgeLineModel(orm.TransientModel): |
|
|
|
attachment_pool = self.pool['ir.attachment'] |
|
|
|
constraint_pool = self.pool['ir.model.constraint'] |
|
|
|
fields_pool = self.pool['ir.model.fields'] |
|
|
|
relation_pool = self.pool['ir.model.relation'] |
|
|
|
|
|
|
|
local_context = (context or {}).copy() |
|
|
|
local_context.update({ |
|
|
@ -86,8 +87,15 @@ class CleanupPurgeLineModel(orm.TransientModel): |
|
|
|
# cannot be instantiated |
|
|
|
fields_pool.unlink(cr, uid, [relation], |
|
|
|
context=local_context) |
|
|
|
except KeyError: |
|
|
|
pass |
|
|
|
except AttributeError: |
|
|
|
pass |
|
|
|
relation_ids = relation_pool.search( |
|
|
|
cr, uid, [('model', '=', line.name)], context=context) |
|
|
|
for relation in relation_ids: |
|
|
|
relation_pool.unlink(cr, uid, [relation], |
|
|
|
context=local_context) |
|
|
|
model_pool.unlink(cr, uid, [row[0]], context=local_context) |
|
|
|
line.write({'purged': True}) |
|
|
|
cr.commit() |
|
|
|