From 309c7422993973963dc1b7c2933ea39451da61fb Mon Sep 17 00:00:00 2001 From: wan Date: Mon, 23 Nov 2020 13:37:36 +0000 Subject: [PATCH] [IMP] account_edi: dot not flush for perfs This reduces the number of cache invalidation and recompute. Because the full environment was not flushed anymore everytime, the test :TestSaleProject.test_project_overview_by_project was failing. closes odoo/odoo#49276 Signed-off-by: Quentin De Paoli (qdp) --- .../models/account_edi_document.py | 4 +-- .../project_profitability_report_analysis.py | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/addons/account_edi/models/account_edi_document.py b/addons/account_edi/models/account_edi_document.py index b1bd59193cd..e7d2ec3ef3b 100644 --- a/addons/account_edi/models/account_edi_document.py +++ b/addons/account_edi/models/account_edi_document.py @@ -142,7 +142,7 @@ class AccountEdiDocument(models.Model): for documents in batches: try: - with self.env.cr.savepoint(): + with self.env.cr.savepoint(flush=False): # Locks the documents in DB. Avoid sending an invoice twice (the documents can be processed by the CRON but also manually). self._cr.execute('SELECT * FROM account_edi_document WHERE id IN %s FOR UPDATE NOWAIT', [tuple(self.ids)]) @@ -165,7 +165,7 @@ class AccountEdiDocument(models.Model): for documents in batches: try: - with self.env.cr.savepoint(): + with self.env.cr.savepoint(flush=False): self._cr.execute('SELECT * FROM account_edi_document WHERE id IN %s FOR UPDATE NOWAIT', [tuple(self.ids)]) if state == 'to_send': diff --git a/addons/sale_timesheet/report/project_profitability_report_analysis.py b/addons/sale_timesheet/report/project_profitability_report_analysis.py index cf9316443d8..4b91925f2b6 100644 --- a/addons/sale_timesheet/report/project_profitability_report_analysis.py +++ b/addons/sale_timesheet/report/project_profitability_report_analysis.py @@ -37,6 +37,37 @@ class ProfitabilityAnalysis(models.Model): help="All revenues that are not from timesheets and that are linked to the analytic account of the project.") margin = fields.Float("Margin", digits=(16, 2), readonly=True, group_operator="sum") + _depends = { + 'sale.order.line': [ + 'order_id', + 'invoice_status', + 'price_reduce', + 'product_id', + 'qty_invoiced', + 'untaxed_amount_invoiced', + 'untaxed_amount_to_invoice', + 'currency_id', + 'company_id', + 'is_downpayment', + 'project_id', + 'task_id', + 'qty_delivered_method', + ], + 'sale.order': [ + 'date_order', + 'user_id', + 'partner_id', + 'currency_id', + 'analytic_account_id', + 'order_line', + 'invoice_status', + 'amount_untaxed', + 'currency_rate', + 'company_id', + 'project_id', + ], + } + def init(self): tools.drop_view_if_exists(self._cr, self._table) query = """