Browse Source

[CHG] Migration to 8.0

[CHG] database_cleanup: move description to README.rst
pull/1408/head
Anthony Muschang 10 years ago
committed by Pedro M. Baeza
parent
commit
a0838f3d58
  1. 15
      database_cleanup/README.rst
  2. 22
      database_cleanup/__openerp__.py
  3. 5
      database_cleanup/model/purge_columns.py
  4. 8
      database_cleanup/model/purge_models.py
  5. 6
      database_cleanup/model/purge_tables.py
  6. 0
      database_cleanup/static/description/icon.png

15
database_cleanup/README.rst

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

22
database_cleanup/__openerp__.py

@ -21,8 +21,8 @@
{ {
'name': 'Database cleanup', 'name': 'Database cleanup',
'version': '0.1',
'author': 'Therp BV',
'version': '8.0.0.1.0',
'author': "Therp BV,Odoo Community Association (OCA)",
'depends': ['base'], 'depends': ['base'],
'license': 'AGPL-3', 'license': 'AGPL-3',
'category': 'Tools', 'category': 'Tools',
@ -34,22 +34,4 @@
'view/purge_data.xml', 'view/purge_data.xml',
'view/menu.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.
""",
} }

5
database_cleanup/model/purge_columns.py

@ -96,8 +96,9 @@ class CleanupPurgeWizardColumn(orm.TransientModel):
columns = list(set([ columns = list(set([
column for model_pool in model_pools column for model_pool in model_pools
for column in model_pool._columns for column in model_pool._columns
if not (isinstance(model_pool._columns[column], fields.function)
and not model_pool._columns[column].store)
if not (isinstance(model_pool._columns[column],
fields.function) and
not model_pool._columns[column].store)
])) ]))
columns += orm.MAGIC_COLUMNS columns += orm.MAGIC_COLUMNS
columns += self.blacklist.get(model_pools[0]._table, []) columns += self.blacklist.get(model_pools[0]._table, [])

8
database_cleanup/model/purge_models.py

@ -52,6 +52,7 @@ class CleanupPurgeLineModel(orm.TransientModel):
attachment_pool = self.pool['ir.attachment'] attachment_pool = self.pool['ir.attachment']
constraint_pool = self.pool['ir.model.constraint'] constraint_pool = self.pool['ir.model.constraint']
fields_pool = self.pool['ir.model.fields'] fields_pool = self.pool['ir.model.fields']
relation_pool = self.pool['ir.model.relation']
local_context = (context or {}).copy() local_context = (context or {}).copy()
local_context.update({ local_context.update({
@ -86,8 +87,15 @@ class CleanupPurgeLineModel(orm.TransientModel):
# cannot be instantiated # cannot be instantiated
fields_pool.unlink(cr, uid, [relation], fields_pool.unlink(cr, uid, [relation],
context=local_context) context=local_context)
except KeyError:
pass
except AttributeError: except AttributeError:
pass 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) model_pool.unlink(cr, uid, [row[0]], context=local_context)
line.write({'purged': True}) line.write({'purged': True})
cr.commit() cr.commit()

6
database_cleanup/model/purge_tables.py

@ -110,9 +110,9 @@ class CleanupPurgeWizardTable(orm.TransientModel):
known_tables += [ known_tables += [
column._sql_names(model_pool)[0] column._sql_names(model_pool)[0]
for column in model_pool._columns.values() for column in model_pool._columns.values()
if column._type == 'many2many'
# unstored function fields of type m2m don't have _rel
and hasattr(column, '_rel')
if (column._type == 'many2many' and
hasattr(column, '_rel')) # unstored function fields of
# type m2m don't have _rel
] ]
# Cannot pass table names as a psycopg argument # Cannot pass table names as a psycopg argument

0
database_cleanup/static/src/img/icon.png → database_cleanup/static/description/icon.png

Before

Width: 200  |  Height: 200  |  Size: 30 KiB

After

Width: 200  |  Height: 200  |  Size: 30 KiB

Loading…
Cancel
Save