From 59aae1ac56663e34a25e9383a5e6d12a23e8c28d Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 2 Feb 2015 12:23:33 +0100 Subject: [PATCH] [IMP] use enumerate pattern for counting --- attachments_to_filesystem/models/ir_attachment.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/attachments_to_filesystem/models/ir_attachment.py b/attachments_to_filesystem/models/ir_attachment.py index d946380d..88152777 100644 --- a/attachments_to_filesystem/models/ir_attachment.py +++ b/attachments_to_filesystem/models/ir_attachment.py @@ -90,9 +90,8 @@ class IrAttachment(Model): attachment_ids = ir_attachment.search( cr, uid, [('db_datas', '!=', False)], limit=limit, context=context) logging.info('moving %d attachments to filestore', len(attachment_ids)) - counter = 1 # 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( cr, uid, [attachment_id], ['datas', 'res_model'], context=context)[0] @@ -111,4 +110,3 @@ class IrAttachment(Model): context=context) if not counter % (len(attachment_ids) / 100 or limit): logging.info('moving attachments: %d done', counter) - counter += 1