You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
780 B

6 years ago
  1. # -*- coding: utf-8 -*-
  2. # Copyright 2018 Camptocamp SA
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from odoo import models
  5. class AbstractReport(models.AbstractModel):
  6. _name = 'report_qweb_abstract'
  7. def _transient_clean_rows_older_than(self, seconds):
  8. assert self._transient, \
  9. "Model %s is not transient, it cannot be vacuumed!" % self._name
  10. # Never delete rows used in last 5 minutes
  11. seconds = max(seconds, 300)
  12. # pylint: disable=sql-injection
  13. query = """
  14. DELETE FROM """ + self._table + """
  15. WHERE
  16. COALESCE(write_date, create_date, (now() at time zone 'UTC'))::timestamp
  17. < ((now() at time zone 'UTC') - interval %s)
  18. """
  19. self.env.cr.execute(query, ("%s seconds" % seconds,))