Browse Source
Merge pull request #455 from StefanRijnhart/imp/10.0/transient_cleaning_sql_p_tombez
Merge pull request #455 from StefanRijnhart/imp/10.0/transient_cleaning_sql_p_tombez
[10.0][IMP] Improve transient models cleaningpull/422/merge
Pedro M. Baeza
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 45 additions and 1 deletions
-
2account_financial_report_qweb/__manifest__.py
-
1account_financial_report_qweb/report/__init__.py
-
22account_financial_report_qweb/report/abstract_report.py
-
5account_financial_report_qweb/report/aged_partner_balance.py
-
4account_financial_report_qweb/report/general_ledger.py
-
5account_financial_report_qweb/report/journal_report.py
-
4account_financial_report_qweb/report/open_items.py
-
3account_financial_report_qweb/report/trial_balance.py
@ -0,0 +1,22 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# Copyright 2018 Camptocamp SA |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
from odoo import models |
||||
|
|
||||
|
|
||||
|
class AbstractReport(models.AbstractModel): |
||||
|
_name = 'report_qweb_abstract' |
||||
|
|
||||
|
def _transient_clean_rows_older_than(self, seconds): |
||||
|
assert self._transient, \ |
||||
|
"Model %s is not transient, it cannot be vacuumed!" % self._name |
||||
|
# Never delete rows used in last 5 minutes |
||||
|
seconds = max(seconds, 300) |
||||
|
query = """ |
||||
|
DELETE FROM """ + self._table + """ |
||||
|
WHERE |
||||
|
COALESCE(write_date, create_date, (now() at time zone 'UTC'))::timestamp |
||||
|
< ((now() at time zone 'UTC') - interval %s) |
||||
|
""" |
||||
|
self.env.cr.execute(query, ("%s seconds" % seconds,)) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue