From f552c9d984f877fcd220f998a0b0f5e5209f70ad Mon Sep 17 00:00:00 2001 From: MuK IT GmbH Date: Sun, 21 Jul 2019 21:00:49 +0000 Subject: [PATCH] publish muk_utils - 12.0 --- muk_utils/models/ir_attachment.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/muk_utils/models/ir_attachment.py b/muk_utils/models/ir_attachment.py index f00e118..7e563f0 100644 --- a/muk_utils/models/ir_attachment.py +++ b/muk_utils/models/ir_attachment.py @@ -102,21 +102,18 @@ class IrAttachment(models.Model): @api.multi def migrate(self, batch_size=None): - batch_size = batch_size or len(self) + batch_size = batch_size or 5 storage_location = self._storage().upper() batches = math.ceil(len(self) / batch_size) - - print(batch_size, batches) - for index, attachment in enumerate(self, start=1): _logger.info("Migrate Attachment %s of %s to %s [Batch %s of %s]", - index % batch_size, math.ceil(index / batch_size), - storage_location, (index / batch_size) + 1, batches + index % batch_size or batch_size, batch_size, storage_location, + math.ceil(index / batch_size), batches ) attachment.with_context(migration=True).write({ 'datas': attachment.datas }) - if not index % batch_size: + if batch_size and not index % batch_size: self.env.cr.commit() #----------------------------------------------------------