[FIX] Error when one attachment cannot be removed.
This commit is contained in:
@@ -191,9 +191,22 @@ class IrLogging(models.Model):
|
||||
if not attachment_ids:
|
||||
return 0
|
||||
|
||||
self.env['ir.attachment'].sudo().browse(attachment_ids).unlink()
|
||||
_logger.info('Deleted %s unneeded filestore attachments', len(attachment_ids))
|
||||
return len(attachment_ids)
|
||||
deleted_count = 0
|
||||
attachments = self.env['ir.attachment'].sudo()
|
||||
for attachment_id in attachment_ids:
|
||||
try:
|
||||
with self.env.cr.savepoint():
|
||||
attachments.browse(attachment_id).unlink()
|
||||
except Exception:
|
||||
_logger.warning(
|
||||
'Could not delete unneeded filestore attachment with id %s',
|
||||
attachment_id,
|
||||
)
|
||||
else:
|
||||
deleted_count += 1
|
||||
|
||||
_logger.info('Deleted %s unneeded filestore attachments', deleted_count)
|
||||
return deleted_count
|
||||
|
||||
def set_db_param(self):
|
||||
## Script to set database expiration date, when enterprise and test env.
|
||||
|
||||
Reference in New Issue
Block a user