Browse Source

publish muk_utils - 12.0

pull/30/head
MuK IT GmbH 5 years ago
parent
commit
f552c9d984
  1. 11
      muk_utils/models/ir_attachment.py

11
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()
#----------------------------------------------------------

Loading…
Cancel
Save