[IMP] account_tax_balance: add index

This indexes improve the display time of
account_tax_balance by a factor of 10 on a database
with 1M move lines.
pull/468/head
Stéphane Bidoul (ACSONE) 2017-08-30 18:51:31 +02:00 committed by Andrea
parent ddd097084c
commit 195a4c1070
3 changed files with 26 additions and 1 deletions

View File

@ -5,7 +5,7 @@
{ {
"name": "Tax Balance", "name": "Tax Balance",
"summary": "Compute tax balances based on date range", "summary": "Compute tax balances based on date range",
"version": "10.0.1.1.0", "version": "10.0.1.1.1",
"category": "Accounting & Finance", "category": "Accounting & Finance",
"website": "https://www.agilebg.com/", "website": "https://www.agilebg.com/",
"author": "Agile Business Group, Therp BV, Tecnativa, ACSONE SA/NV, " "author": "Agile Business Group, Therp BV, Tecnativa, ACSONE SA/NV, "

View File

@ -4,3 +4,4 @@
from . import account_move from . import account_move
from . import account_tax from . import account_tax
from . import account_move_line

View File

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Copyright 2017 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, models
class AccountMoveLine(models.Model):
_inherit = 'account.move.line'
@api.model_cr
def init(self):
res = super(AccountMoveLine, self).init()
self._cr.execute("""
SELECT indexname FROM pg_indexes
WHERE indexname = 'account_move_line_date_tax_line_id_idx'
""")
if not self._cr.fetchone():
self._cr.execute("""
CREATE INDEX account_move_line_date_tax_line_id_idx
ON account_move_line (date, tax_line_id)
""")
return res