Browse Source
[9.0][IMP] Improve transient models cleaning (#441)
[9.0][IMP] Improve transient models cleaning (#441)
* [9.0][IMP] Improve transient models cleaningpull/643/head
Patrick Tombez
6 years ago
committed by
Stefan Rijnhart (Opener)
7 changed files with 40 additions and 1 deletions
-
2account_financial_report_qweb/__openerp__.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
-
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 openerp import models |
||||
|
|
||||
|
|
||||
|
class AbstractReport(models.AbstractModel): |
||||
|
_name = 'report_qweb_abstract' |
||||
|
|
||||
|
def _transient_clean_rows_older_than(self, cr, 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) |
||||
|
""" |
||||
|
cr.execute(query, ("%s seconds" % seconds,)) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue