Real fix for PEP8 errors
parent
131cf140f3
commit
c61521b3c3
|
@ -38,28 +38,35 @@ class import_odbc_dbtable(orm.Model):
|
|||
'dbsource_id': fields.many2one('base.external.dbsource',
|
||||
'Database source', required=True),
|
||||
'sql_source': fields.text('SQL', required=True,
|
||||
help='Column names must be valid "import_data" columns.'),
|
||||
help='Column names must be valid \
|
||||
"import_data" columns.'),
|
||||
'model_target': fields.many2one('ir.model', 'Target object'),
|
||||
'noupdate': fields.boolean('No updates',
|
||||
help="Only create new records;\
|
||||
disable updates to existing records."),
|
||||
'exec_order': fields.integer('Execution order',
|
||||
help="Defines the order to perform the import"),
|
||||
help="Defines the order to perform \
|
||||
the import"),
|
||||
'last_sync': fields.datetime('Last sync date',
|
||||
help="Datetime for the last succesfull sync.\
|
||||
\nLater changes on the source may not be replicated on \
|
||||
the destination"),
|
||||
help="Datetime for the last succesfull \
|
||||
sync. \nLater changes on the source may \
|
||||
not be replicated on the destination"),
|
||||
'start_run': fields.datetime('Time started', readonly=True),
|
||||
'last_run': fields.datetime('Time ended', readonly=True),
|
||||
'last_record_count': fields.integer('Last record count', readonly=True),
|
||||
'last_record_count': fields.integer('Last record count',
|
||||
readonly=True),
|
||||
'last_error_count': fields.integer('Last error count', readonly=True),
|
||||
'last_warn_count': fields.integer('Last warning count', readonly=True),
|
||||
'last_log': fields.text('Last run log', readonly=True),
|
||||
'ignore_rel_errors': fields.boolean('Ignore relationship errors',
|
||||
help="On error try to reimport rows ignoring relationships."),
|
||||
help="On error try to reimport \
|
||||
rows ignoring relationships."),
|
||||
'raise_import_errors': fields.boolean('Raise import errors',
|
||||
help="Import errors not handled, intended for debugging purposes.\
|
||||
\nAlso forces debug messages to be written to the server log."),
|
||||
help="Import errors not \
|
||||
handled, intended for \
|
||||
debugging purposes. \nAlso \
|
||||
forces debug messages to be \
|
||||
written to the server log."),
|
||||
}
|
||||
_defaults = {
|
||||
'enabled': True,
|
||||
|
@ -166,13 +173,15 @@ class import_odbc_dbtable(orm.Model):
|
|||
obj.sql_source, params, metadata=True)
|
||||
|
||||
# Exclude columns titled "None"; add (xml_)"id" column
|
||||
cidx = [i for i, x in enumerate(res['cols']) if x.upper() != 'NONE']
|
||||
cols = ([x for i, x in enumerate(res['cols']) if x.upper() != 'NONE']
|
||||
+ ['id'])
|
||||
cidx = ([i for i, x in enumerate(res['cols'])
|
||||
if x.upper() != 'NONE'])
|
||||
cols = ([x for i, x in enumerate(res['cols'])
|
||||
if x.upper() != 'NONE'] + ['id'])
|
||||
|
||||
# Import each row:
|
||||
for row in res['rows']:
|
||||
# Build data row; import only columns present in the "cols" list
|
||||
# Build data row;
|
||||
# import only columns present in the "cols" list
|
||||
data = list()
|
||||
for i in cidx:
|
||||
# TODO: Handle imported datetimes properly
|
||||
|
@ -200,13 +209,15 @@ class import_odbc_dbtable(orm.Model):
|
|||
if log['last_error_count']:
|
||||
level = logging.ERROR
|
||||
_logger.log(level,
|
||||
'Imported %s , %d rows, %d errors, %d warnings.' % (
|
||||
model_name, log['last_record_count'], log['last_error_count'],
|
||||
'Imported %s , %d rows, %d errors, %d warnings.' %
|
||||
(model_name, log['last_record_count'],
|
||||
log['last_error_count'],
|
||||
log['last_warn_count']))
|
||||
# Write run log, either if the table import is active or inactive
|
||||
if log['last_log']:
|
||||
log['last_log'].insert(0,
|
||||
'LEVEL|== Line == |== Relationship ==|== Message ==')
|
||||
'LEVEL|== Line == |== Relationship \
|
||||
==|== Message ==')
|
||||
log.update({'last_log': '\n'.join(log['last_log'])})
|
||||
log.update({'last_run': datetime.now().replace(microsecond=0)})
|
||||
self.write(cr, uid, [obj.id], log)
|
||||
|
|
Loading…
Reference in New Issue