[CHG] Migration to 8.0
[CHG] database_cleanup: move description to README.rstpull/2684/head
parent
b8e24140f7
commit
e5e76d0e94
|
@ -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.
|
|
@ -21,8 +21,8 @@
|
||||||
|
|
||||||
{
|
{
|
||||||
'name': 'Database cleanup',
|
'name': 'Database cleanup',
|
||||||
'version': '0.1',
|
'version': '8.0.0.1.0',
|
||||||
'author': 'Therp BV',
|
'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.
|
|
||||||
""",
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
if not (isinstance(model_pool._columns[column],
|
||||||
and not model_pool._columns[column].store)
|
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, [])
|
||||||
|
|
|
@ -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()
|
||||||
|
|
|
@ -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'
|
if (column._type == 'many2many' and
|
||||||
# unstored function fields of type m2m don't have _rel
|
hasattr(column, '_rel')) # unstored function fields of
|
||||||
and hasattr(column, '_rel')
|
# type m2m don't have _rel
|
||||||
]
|
]
|
||||||
|
|
||||||
# Cannot pass table names as a psycopg argument
|
# Cannot pass table names as a psycopg argument
|
||||||
|
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
Loading…
Reference in New Issue