diff options
| author | Julien Castiaux <juc@odoo.com> | 2020-03-17 11:58:14 +0000 |
|---|---|---|
| committer | Raphael Collet <rco@odoo.com> | 2020-05-19 13:38:19 +0000 |
| commit | c5d3a109f530cd0763a1c3860086b5b7abef1b64 (patch) | |
| tree | 559f2f3e61c0e54ca40c25a7740e6dff2a768b9f /addons/mail/models/mail_thread.py | |
| parent | 64873d225ede01eb3116773b2ff0aed278ff0e6a (diff) | |
[REF] ir.autovacuum: declarative garbage collector registration
The ir.autovacuum model purpose is to run several garbage collecting
operations like removing files from the filestore when no attachment
references them anymore.
The precedent strategy to register new garbage collection tasks was to
override the `power_on` method and to imperatively execute a vacuum
cleaning method on a given model. All calls were executed in a single
SQL transaction without any error handling, meaning a single fail during
any call resulted in a complete failure of the entire vacuum cleaning
chain.
We introduce a new `@autovacuum` api decorator, its purpose it to
register garbage collecting methods that will be safely executed in
their own transaction by the vacuum cleaner. In order to ensure this
new strategy is used, we deprecate `power_on` extensions.
By the way, garbage-collecting methods can be quite heavy and we don't
want users to directly call them. We now ensure they are private.
closes odoo/odoo#47842
Task: 2154079
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Co-authored-by: Raphael Collet <rco@odoo.com>
Co-authored-by: Olivier Dony <odo@odoo.com>
Diffstat (limited to 'addons/mail/models/mail_thread.py')
| -rw-r--r-- | addons/mail/models/mail_thread.py | 19 |
1 files changed, 0 insertions, 19 deletions
diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 349396ee0a4..5786a4ed357 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -478,25 +478,6 @@ class MailThread(models.AbstractModel): return self @api.model - def _garbage_collect_attachments(self): - """ Garbage collect lost mail attachments. Those are attachments - - linked to res_model 'mail.compose.message', the composer wizard - - with res_id 0, because they were created outside of an existing - wizard (typically user input through Chatter or reports - created on-the-fly by the templates) - - unused since at least one day (create_date and write_date) - """ - limit_date = datetime.datetime.utcnow() - datetime.timedelta(days=1) - limit_date_str = datetime.datetime.strftime(limit_date, tools.DEFAULT_SERVER_DATETIME_FORMAT) - self.env['ir.attachment'].search([ - ('res_model', '=', 'mail.compose.message'), - ('res_id', '=', 0), - ('create_date', '<', limit_date_str), - ('write_date', '<', limit_date_str)] - ).unlink() - return True - - @api.model def get_mail_message_access(self, res_ids, operation, model_name=None): """ mail.message check permission rules for related document. This method is meant to be inherited in order to implement addons-specific behavior. |
