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.

21 lines
730 B

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