Browse Source
[11.0][IMP] Improve transient models cleaning
[11.0][IMP] Improve transient models cleaning
When there are a lot of account.move.line (several millions) and print any of the Qweb reports, that will generate also a lot of transient objects. As these objects are created with an "insert" query, the cleaning normally triggered by the count of the records in transient tables is not done, so only the cleaning based on the age of the records is processed (by default, records older than 1 hours are deleted), but the cron task is only ran one time per day. For large setups this can lead to memory errors at that point. This change prevents the memory error by executing the transient record cleanup for the report models in this module in SQL.pull/749/head
Patrick Tombez
6 years ago
committed by
João Marques
10 changed files with 60 additions and 6 deletions
-
2account_financial_report/__manifest__.py
-
18account_financial_report/i18n/account_financial_report.pot
-
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