Browse Source
Merge pull request #456 from StefanRijnhart/imp/11.0/transient_cleaning_sql_p_tombez
Merge pull request #456 from StefanRijnhart/imp/11.0/transient_cleaning_sql_p_tombez
[11.0][IMP] Improve transient models cleaningpull/457/head
Pedro M. Baeza
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 47 additions and 1 deletions
-
2account_financial_report/__manifest__.py
-
1account_financial_report/report/__init__.py
-
21account_financial_report/report/abstract_report.py
-
5account_financial_report/report/aged_partner_balance.py
-
4account_financial_report/report/general_ledger.py
-
5account_financial_report/report/journal_ledger.py
-
4account_financial_report/report/open_items.py
-
3account_financial_report/report/trial_balance.py
-
3account_financial_report/report/vat_report.py
@ -0,0 +1,21 @@ |
|||||
|
# 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 = 'account_financial_report_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, self.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