[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
parent
ddd097084c
commit
195a4c1070
|
@ -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, "
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
Loading…
Reference in New Issue