From e5b00ee0d2c62b7b49ba9adb127f64602d34dfb3 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Tue, 20 Jun 2017 15:06:14 +0200 Subject: [PATCH] [ADD] cap the amount of documents to ocr per cronjob run --- document_ocr/data/ir_cron.xml | 1 + document_ocr/models/ir_attachment.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/document_ocr/data/ir_cron.xml b/document_ocr/data/ir_cron.xml index f69d151a..1ea8cd20 100644 --- a/document_ocr/data/ir_cron.xml +++ b/document_ocr/data/ir_cron.xml @@ -8,6 +8,7 @@ ir.attachment _ocr_cron -1 + (100,) diff --git a/document_ocr/models/ir_attachment.py b/document_ocr/models/ir_attachment.py index ec161712..7a69a718 100644 --- a/document_ocr/models/ir_attachment.py +++ b/document_ocr/models/ir_attachment.py @@ -70,10 +70,10 @@ class IrAttachment(models.Model): return StringIO(stdout) @api.model - def _ocr_cron(self): + def _ocr_cron(self, limit=0): for this in self.with_context(document_ocr_force=True).search([ ('index_content', '=', _MARKER_PHRASE), - ]): + ], limit=limit): if not this.datas: continue file_type, index_content = this._index(