[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) <qdp@openerp.com>
This commit is contained in:
wan
2021-01-22 10:14:48 +00:00
parent 05dd0f6460
commit 309c742299
2 changed files with 33 additions and 2 deletions
@@ -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':
@@ -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 = """