This question has been flagged
2 Replies
14115 Views

I've started to use Maintenance module and noticed that files in filestore directory are not removed after deleting attachments. Is any simple method to make a cleanup of unused files or I need to write a script which will be doing it?

 I know, that using hash of files instead of real names is useful when the same files are attached many times and therefore is not so easy to delete file directly after removing attachment but I hope a cron script would be very desired.

Odoo v.11


Avatar
Discard
Author Best Answer

Self-answer. I found that Odoo makes such cleanup  automatically (in my instalation twice a day) then described problem does not exist. A few houres later filestore directory was freed from unnecessary files.

Odoo v. 12 not 11 as noticed in previous post.

Avatar
Discard
Best Answer

Just to fill inn what I found out. The job that does this is called

Base: Auto-vacuum internal data

and lives here:


class AutoVacuum(models.AbstractModel):
""" Expose the vacuum method to the cron jobs mechanism. """
_name = 'ir.autovacuum'
_description = 'Automatic Vacuum'
.
.
.
@api.model
def power_on(self, *args, **kwargs):
if not self.env.user._is_admin():
raise AccessDenied()
self.env['ir.attachment']._file_gc()
self._gc_transient_models()
self._gc_user_logs()
return True
Avatar
Discard