From d3f183981c2750ff0ff1f2c7cf4907aac23e8c04 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Wed, 16 Sep 2015 08:21:29 +0200 Subject: [PATCH] [ADD] allow to set maximum number of records to reindex --- document_reindex/models/ir_attachment.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/document_reindex/models/ir_attachment.py b/document_reindex/models/ir_attachment.py index 4113bec0..e869ff68 100644 --- a/document_reindex/models/ir_attachment.py +++ b/document_reindex/models/ir_attachment.py @@ -46,9 +46,8 @@ class IrAttachment(models.Model): continue @api.model - def document_reindex_domain(self, domain, limit=100): + def document_reindex_domain(self, domain, limit=100, max_records=0): offset = 0 - counter = 0 limit = int( self.env['ir.config_parameter'].get_param( 'document_reindex.limit', '0')) or limit @@ -59,9 +58,10 @@ class IrAttachment(models.Model): if not attachments: return attachments.document_reindex() - logging.info('%d done', counter * limit + len(attachments)) + logging.info('%d done', offset + len(attachments)) offset += len(attachments) - counter += 1 + if max_records and offset > max_records: + break @api.model def document_reindex_all(self):