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
855 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. from psycopg2.extensions import AsIs
  5. class AbstractReport(models.AbstractModel):
  6. _name = 'account_financial_report_abstract'
  7. _description = 'Abstract Report'
  8. def _transient_clean_rows_older_than(self, seconds):
  9. assert self._transient, \
  10. "Model %s is not transient, it cannot be vacuumed!" % self._name
  11. # Never delete rows used in last 5 minutes
  12. seconds = max(seconds, 300)
  13. query = (
  14. "DELETE FROM %s"
  15. " WHERE COALESCE("
  16. "write_date, create_date, (now() at time zone 'UTC'))"
  17. "::timestamp < ((now() at time zone 'UTC') - interval %s)"
  18. )
  19. self.env.cr.execute(query, (AsIs(self._table), "%s seconds" % seconds))