[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.
This commit is contained in:
Patrick Tombez
2018-08-21 12:09:53 +02:00
committed by chaule97
parent ef17d5b23c
commit 72f201674d
10 changed files with 60 additions and 6 deletions

View File

@@ -17,6 +17,7 @@ class OpenItemsReport(models.TransientModel):
"""
_name = 'report_open_items'
_inherit = 'account_financial_report_abstract'
# Filters fields, used for data computation
date_at = fields.Date()
@@ -37,6 +38,7 @@ class OpenItemsReport(models.TransientModel):
class OpenItemsReportAccount(models.TransientModel):
_name = 'report_open_items_account'
_inherit = 'account_financial_report_abstract'
_order = 'code ASC'
report_id = fields.Many2one(
@@ -70,6 +72,7 @@ class OpenItemsReportAccount(models.TransientModel):
class OpenItemsReportPartner(models.TransientModel):
_name = 'report_open_items_partner'
_inherit = 'account_financial_report_abstract'
report_account_id = fields.Many2one(
comodel_name='report_open_items_account',
@@ -114,6 +117,7 @@ ORDER BY
class OpenItemsReportMoveLine(models.TransientModel):
_name = 'report_open_items_move_line'
_inherit = 'account_financial_report_abstract'
report_partner_id = fields.Many2one(
comodel_name='report_open_items_partner',