From beb84c7c5943ad46a49107f3ee546ecb04d21f1b Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Wed, 18 Feb 2015 19:23:25 +0100 Subject: [PATCH] [IMP] Scale up number of processed attachments a little bit [FIX] Actually truncate the list of ids to length of --- attachment_file_type/data/ir_cron.xml | 2 +- attachment_file_type/models/ir_attachment.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/attachment_file_type/data/ir_cron.xml b/attachment_file_type/data/ir_cron.xml index 4911b9f1..dccde8c5 100644 --- a/attachment_file_type/data/ir_cron.xml +++ b/attachment_file_type/data/ir_cron.xml @@ -11,7 +11,7 @@ ir.attachment update_file_type_from_cron - (1000,) + (10000,) diff --git a/attachment_file_type/models/ir_attachment.py b/attachment_file_type/models/ir_attachment.py index 26ec2bf9..4488da9a 100644 --- a/attachment_file_type/models/ir_attachment.py +++ b/attachment_file_type/models/ir_attachment.py @@ -26,13 +26,19 @@ from base64 import b64decode class Attachment(orm.Model): _inherit = 'ir.attachment' - def update_file_type_from_cron(self, cr, uid, count=1000, context=None): + def update_file_type_from_cron(self, cr, uid, count=10000, context=None): ids = self.search( cr, uid, [('file_type', '=', False)], context=context) logging.getLogger('openerp.addons.attachment_file_type').info( 'Found %s attachments without file type in the database.', len(ids)) - self.update_file_type(cr, uid, ids, force=True, context=None) + if ids: + logging.getLogger('openerp.addons.attachment_file_type').info( + 'Providing file types for a maximum of %s of them', + count) + return self.update_file_type( + cr, uid, ids[:count], force=True, context=None) + return False def update_file_type(self, cr, uid, ids, force=False, context=None): """ Write the file types for these attachments. If the document module