[RFR] Flake8
parent
b0da1f4fb9
commit
addc2d5b4f
|
@ -36,8 +36,8 @@
|
|||
],
|
||||
'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.
|
||||
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
|
||||
|
|
|
@ -53,7 +53,7 @@ class CleanupPurgeLineColumn(orm.TransientModel):
|
|||
'WHERE attrelid = '
|
||||
'( SELECT oid FROM pg_class WHERE relname = %s ) '
|
||||
'AND attname = %s',
|
||||
(model_pool._table, line.name));
|
||||
(model_pool._table, line.name))
|
||||
if not cr.fetchone()[0]:
|
||||
continue
|
||||
|
||||
|
@ -68,6 +68,7 @@ class CleanupPurgeLineColumn(orm.TransientModel):
|
|||
cr.commit()
|
||||
return True
|
||||
|
||||
|
||||
class CleanupPurgeWizardColumn(orm.TransientModel):
|
||||
_inherit = 'cleanup.purge.wizard'
|
||||
_name = 'cleanup.purge.wizard.column'
|
||||
|
@ -75,7 +76,7 @@ class CleanupPurgeWizardColumn(orm.TransientModel):
|
|||
# List of known columns in use without corresponding fields
|
||||
# Format: {table: [fields]}
|
||||
blacklist = {
|
||||
'wkf_instance': ['uid'], # lp:1277899
|
||||
'wkf_instance': ['uid'], # lp:1277899
|
||||
}
|
||||
|
||||
def default_get(self, cr, uid, fields, context=None):
|
||||
|
@ -123,7 +124,6 @@ class CleanupPurgeWizardColumn(orm.TransientModel):
|
|||
res = []
|
||||
model_pool = self.pool['ir.model']
|
||||
model_ids = model_pool.search(cr, uid, [], context=context)
|
||||
line_pool = self.pool['cleanup.purge.line.column']
|
||||
|
||||
# mapping of tables to tuples (model id, [pool1, pool2, ...])
|
||||
table2model = {}
|
||||
|
@ -132,7 +132,8 @@ class CleanupPurgeWizardColumn(orm.TransientModel):
|
|||
model_pool = self.pool.get(model.model)
|
||||
if not model_pool or not model_pool._auto:
|
||||
continue
|
||||
table2model.setdefault(model_pool._table, (model.id, []))[1].append(model_pool)
|
||||
table2model.setdefault(
|
||||
model_pool._table, (model.id, []))[1].append(model_pool)
|
||||
|
||||
for table, model_spec in table2model.iteritems():
|
||||
for column in self.get_orphaned_columns(
|
||||
|
|
|
@ -48,6 +48,7 @@ class CleanupPurgeLineData(orm.TransientModel):
|
|||
self.pool['ir.model.data'].unlink(cr, uid, data_ids, context=context)
|
||||
return self.write(cr, uid, ids, {'purged': True}, context=context)
|
||||
|
||||
|
||||
class CleanupPurgeWizardData(orm.TransientModel):
|
||||
_inherit = 'cleanup.purge.wizard'
|
||||
_name = 'cleanup.purge.wizard.data'
|
||||
|
|
|
@ -53,11 +53,11 @@ class CleanupPurgeLineModel(orm.TransientModel):
|
|||
constraint_pool = self.pool['ir.model.constraint']
|
||||
fields_pool = self.pool['ir.model.fields']
|
||||
|
||||
local_context=(context or {}).copy()
|
||||
local_context = (context or {}).copy()
|
||||
local_context.update({
|
||||
MODULE_UNINSTALL_FLAG: True,
|
||||
'no_drop_table': True,
|
||||
})
|
||||
MODULE_UNINSTALL_FLAG: True,
|
||||
'no_drop_table': True,
|
||||
})
|
||||
|
||||
for line in self.browse(cr, uid, ids, context=context):
|
||||
cr.execute(
|
||||
|
|
|
@ -56,8 +56,8 @@ class CleanupPurgeLineTable(orm.TransientModel):
|
|||
FROM pg_attribute af, pg_attribute a,
|
||||
(SELECT conname, conrelid, confrelid,conkey[i] AS conkey,
|
||||
confkey[i] AS confkey
|
||||
FROM (select conname, conrelid, confrelid, conkey, confkey,
|
||||
generate_series(1,array_upper(conkey,1)) AS i
|
||||
FROM (select conname, conrelid, confrelid, conkey,
|
||||
confkey, generate_series(1,array_upper(conkey,1)) AS i
|
||||
FROM pg_constraint WHERE contype = 'f') ss) ss2
|
||||
WHERE af.attnum = confkey AND af.attrelid = confrelid AND
|
||||
a.attnum = conkey AND a.attrelid = conrelid
|
||||
|
@ -80,6 +80,7 @@ class CleanupPurgeLineTable(orm.TransientModel):
|
|||
cr.commit()
|
||||
return True
|
||||
|
||||
|
||||
class CleanupPurgeWizardTable(orm.TransientModel):
|
||||
_inherit = 'cleanup.purge.wizard'
|
||||
_name = 'cleanup.purge.wizard.table'
|
||||
|
@ -97,7 +98,6 @@ class CleanupPurgeWizardTable(orm.TransientModel):
|
|||
Ignore views for now.
|
||||
"""
|
||||
model_ids = self.pool['ir.model'].search(cr, uid, [], context=context)
|
||||
line_pool = self.pool['cleanup.purge.line.table']
|
||||
# Start out with known tables with no model
|
||||
known_tables = ['wkf_witm_trans']
|
||||
for model in self.pool['ir.model'].browse(
|
||||
|
|
|
@ -36,6 +36,7 @@ class CleanupPurgeLine(orm.AbstractModel):
|
|||
def purge(self, cr, uid, ids, context=None):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class PurgeWizard(orm.AbstractModel):
|
||||
""" Abstract base class for the purge wizards """
|
||||
_name = 'cleanup.purge.wizard'
|
||||
|
|
Loading…
Reference in New Issue