Welcome!

Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.

Sign up

You need to be registered to interact with the community.
This question has been flagged
1 Reply
9 Views

Hey Cyllo users, best way to handle `@api.autovacuum`? Should I use a cron job, or is there a better approach within Cyllo itself?

Avatar
Discard

Here's how you can use the `@api.autovacuum` decorator to schedule a cleanup task. This will integrate your cleanup method into Odoo's automated vacuum process. The '@api.autovacuum' method decorator allows you to mark a method so that it runs as part of the daily vacuum cron job (model 'ir.autovacuum'). This is useful for tasks similar to garbage collection, which help manage resources but don’t require a separate cron job. By using this decorator, you can ensure that necessary maintenance tasks are performed automatically on a regular basis without needing to set up individual cron jobs for each task. class SomeModel(models.Model): _name = 'your.model' @api.autovacuum def _cleanup_old_records(self): old_records = self.search([('create_date', '<', fields.Datetime.subtract(days=30))]) old_records.unlink()

Avatar
Discard

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!