[IMP] use enumerate pattern for counting

This commit is contained in:
Holger Brunn 2015-02-02 12:23:33 +01:00
parent 200b894bce
commit 59aae1ac56

View File

@ -90,9 +90,8 @@ class IrAttachment(Model):
attachment_ids = ir_attachment.search( attachment_ids = ir_attachment.search(
cr, uid, [('db_datas', '!=', False)], limit=limit, context=context) cr, uid, [('db_datas', '!=', False)], limit=limit, context=context)
logging.info('moving %d attachments to filestore', len(attachment_ids)) logging.info('moving %d attachments to filestore', len(attachment_ids))
counter = 1
# attachments can be big, so we read every attachment on its own # attachments can be big, so we read every attachment on its own
for attachment_id in attachment_ids: for counter, attachment_id in enumerate(attachment_ids, start=1)
attachment_data = ir_attachment.read( attachment_data = ir_attachment.read(
cr, uid, [attachment_id], ['datas', 'res_model'], cr, uid, [attachment_id], ['datas', 'res_model'],
context=context)[0] context=context)[0]
@ -111,4 +110,3 @@ class IrAttachment(Model):
context=context) context=context)
if not counter % (len(attachment_ids) / 100 or limit): if not counter % (len(attachment_ids) / 100 or limit):
logging.info('moving attachments: %d done', counter) logging.info('moving attachments: %d done', counter)
counter += 1