[account_financial_report]
- minor usability fixes for multicompany - improve performance of general ledger using a new indexpull/499/head
parent
778ccf9bc1
commit
50c23ecec5
|
@ -1,2 +1,3 @@
|
|||
from . import account
|
||||
from . import account_group
|
||||
from . import account_move_line
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2019 ACSONE SA/NV (<http://acsone.eu>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).-
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class AccountMoveLine(models.Model):
|
||||
_inherit = 'account.move.line'
|
||||
|
||||
@api.model_cr
|
||||
def init(self):
|
||||
"""
|
||||
The join between accounts_partners subquery and account_move_line
|
||||
can be heavy to compute on big databases.
|
||||
Join sample:
|
||||
JOIN
|
||||
account_move_line ml
|
||||
ON ap.account_id = ml.account_id
|
||||
AND ml.date < '2018-12-30'
|
||||
AND ap.partner_id = ml.partner_id
|
||||
AND ap.include_initial_balance = TRUE
|
||||
By adding the following index, performances are strongly increased.
|
||||
:return:
|
||||
"""
|
||||
self._cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = '
|
||||
'%s',
|
||||
('account_move_line_account_id_partner_id_index',))
|
||||
if not self._cr.fetchone():
|
||||
self._cr.execute("""
|
||||
CREATE INDEX account_move_line_account_id_partner_id_index
|
||||
ON account_move_line (account_id, partner_id)""")
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
* Handle better multicompany behaviour
|
||||
* Improve how title appears in the reports
|
||||
* Improve performance in General Ledger
|
||||
|
||||
|
||||
11.0.2.3.1 (2018-11-29)
|
||||
|
|
|
@ -41,7 +41,7 @@ class AbstractReportXslx(models.AbstractModel):
|
|||
|
||||
self._define_formats(workbook)
|
||||
|
||||
report_name = self._get_report_name(objects)
|
||||
report_name = self._get_report_name(report)
|
||||
report_footer = self._get_report_footer()
|
||||
filters = self._get_report_filters(report)
|
||||
self.columns = self._get_report_columns(report)
|
||||
|
@ -349,7 +349,7 @@ class AbstractReportXslx(models.AbstractModel):
|
|||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def _get_report_name(self, objects):
|
||||
def _get_report_name(self, report):
|
||||
"""
|
||||
Allow to define the report name.
|
||||
Report name will be used as sheet name and as report title.
|
||||
|
|
|
@ -10,8 +10,7 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
|
|||
_name = 'report.a_f_r.report_aged_partner_balance_xlsx'
|
||||
_inherit = 'report.account_financial_report.abstract_report_xlsx'
|
||||
|
||||
def _get_report_name(self, objects):
|
||||
report = objects
|
||||
def _get_report_name(self, report):
|
||||
return _('Aged Partner Balance - %s - %s') % (
|
||||
report.company_id.name, report.company_id.currency_id.name)
|
||||
|
||||
|
|
|
@ -11,8 +11,7 @@ class GeneralLedgerXslx(models.AbstractModel):
|
|||
_name = 'report.a_f_r.report_general_ledger_xlsx'
|
||||
_inherit = 'report.account_financial_report.abstract_report_xlsx'
|
||||
|
||||
def _get_report_name(self, objects):
|
||||
report = objects
|
||||
def _get_report_name(self, report):
|
||||
return _('General Ledger - %s - %s') % (
|
||||
report.company_id.name, report.company_id.currency_id.name)
|
||||
|
||||
|
|
|
@ -10,8 +10,7 @@ class JournalLedgerXslx(models.AbstractModel):
|
|||
_name = 'report.a_f_r.report_journal_ledger_xlsx'
|
||||
_inherit = 'report.account_financial_report.abstract_report_xlsx'
|
||||
|
||||
def _get_report_name(self, objects):
|
||||
report = objects
|
||||
def _get_report_name(self, report):
|
||||
return _('Journal Ledger - %s - %s') % (
|
||||
report.company_id.name, report.company_id.currency_id.name)
|
||||
|
||||
|
|
|
@ -9,8 +9,7 @@ class OpenItemsXslx(models.AbstractModel):
|
|||
_name = 'report.a_f_r.report_open_items_xlsx'
|
||||
_inherit = 'report.account_financial_report.abstract_report_xlsx'
|
||||
|
||||
def _get_report_name(self, objects):
|
||||
report = objects
|
||||
def _get_report_name(self, report):
|
||||
return _('Open Items - %s - %s') % (
|
||||
report.company_id.name, report.company_id.currency_id.name)
|
||||
|
||||
|
|
|
@ -10,8 +10,7 @@ class TrialBalanceXslx(models.AbstractModel):
|
|||
_name = 'report.a_f_r.report_trial_balance_xlsx'
|
||||
_inherit = 'report.account_financial_report.abstract_report_xlsx'
|
||||
|
||||
def _get_report_name(self, objects):
|
||||
report = objects
|
||||
def _get_report_name(self, report):
|
||||
return _('Trial Balance - %s - %s') % (
|
||||
report.company_id.name, report.company_id.currency_id.name)
|
||||
|
||||
|
|
|
@ -8,8 +8,7 @@ class VATReportXslx(models.AbstractModel):
|
|||
_name = 'report.a_f_r.report_vat_report_xlsx'
|
||||
_inherit = 'report.account_financial_report.abstract_report_xlsx'
|
||||
|
||||
def _get_report_name(self, objects):
|
||||
report = objects
|
||||
def _get_report_name(self, report):
|
||||
return _('VAT Report - %s - %s') % (
|
||||
report.company_id.name, report.company_id.currency_id.name)
|
||||
|
||||
|
|
|
@ -103,6 +103,10 @@ class GeneralLedgerReportWizard(models.TransientModel):
|
|||
if self.company_id and self.date_range_id.company_id and \
|
||||
self.date_range_id.company_id != self.company_id:
|
||||
self.date_range_id = False
|
||||
if self.company_id and self.account_journal_ids:
|
||||
self.account_journal_ids = self.account_journal_ids.filtered(
|
||||
lambda p: p.company_id == self.company_id or
|
||||
not p.company_id)
|
||||
if self.company_id and self.partner_ids:
|
||||
self.partner_ids = self.partner_ids.filtered(
|
||||
lambda p: p.company_id == self.company_id or
|
||||
|
@ -118,6 +122,7 @@ class GeneralLedgerReportWizard(models.TransientModel):
|
|||
lambda c: c.company_id == self.company_id)
|
||||
res = {'domain': {'account_ids': [],
|
||||
'partner_ids': [],
|
||||
'account_journal_ids': [],
|
||||
'cost_center_ids': [],
|
||||
'date_range_id': []
|
||||
}
|
||||
|
@ -127,6 +132,8 @@ class GeneralLedgerReportWizard(models.TransientModel):
|
|||
else:
|
||||
res['domain']['account_ids'] += [
|
||||
('company_id', '=', self.company_id.id)]
|
||||
res['domain']['account_journal_ids'] += [
|
||||
('company_id', '=', self.company_id.id)]
|
||||
res['domain']['partner_ids'] += [
|
||||
'|', ('company_id', '=', self.company_id.id),
|
||||
('company_id', '=', False)]
|
||||
|
|
Loading…
Reference in New Issue