Browse Source
[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/343/head
Stéphane Bidoul (ACSONE)
7 years ago
No known key found for this signature in database
GPG Key ID: 866D394B4986F82D
3 changed files with
26 additions and
1 deletions
-
account_tax_balance/__manifest__.py
-
account_tax_balance/models/__init__.py
-
account_tax_balance/models/account_move_line.py
|
|
@ -5,7 +5,7 @@ |
|
|
|
{ |
|
|
|
"name": "Tax Balance", |
|
|
|
"summary": "Compute tax balances based on date range", |
|
|
|
"version": "10.0.1.1.0", |
|
|
|
"version": "10.0.1.1.1", |
|
|
|
"category": "Accounting & Finance", |
|
|
|
"website": "https://www.agilebg.com/", |
|
|
|
"author": "Agile Business Group, Therp BV, Tecnativa, ACSONE SA/NV, " |
|
|
|
|
|
@ -4,3 +4,4 @@ |
|
|
|
|
|
|
|
from . import account_move |
|
|
|
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 |