Browse Source

[account_financial_report]

- minor usability fixes for multicompany
- improve performance of general ledger using a new index
pull/499/head
Jordi Ballester Alomar 6 years ago
parent
commit
50c23ecec5
  1. 1
      account_financial_report/models/__init__.py
  2. 31
      account_financial_report/models/account_move_line.py
  3. 1
      account_financial_report/readme/HISTORY.rst
  4. 4
      account_financial_report/report/abstract_report_xlsx.py
  5. 3
      account_financial_report/report/aged_partner_balance_xlsx.py
  6. 3
      account_financial_report/report/general_ledger_xlsx.py
  7. 3
      account_financial_report/report/journal_ledger_xlsx.py
  8. 3
      account_financial_report/report/open_items_xlsx.py
  9. 3
      account_financial_report/report/trial_balance_xlsx.py
  10. 3
      account_financial_report/report/vat_report_xlsx.py
  11. 7
      account_financial_report/wizard/general_ledger_wizard.py

1
account_financial_report/models/__init__.py

@ -1,2 +1,3 @@
from . import account from . import account
from . import account_group from . import account_group
from . import account_move_line

31
account_financial_report/models/account_move_line.py

@ -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)""")

1
account_financial_report/readme/HISTORY.rst

@ -3,6 +3,7 @@
* Handle better multicompany behaviour * Handle better multicompany behaviour
* Improve how title appears in the reports * Improve how title appears in the reports
* Improve performance in General Ledger
11.0.2.3.1 (2018-11-29) 11.0.2.3.1 (2018-11-29)

4
account_financial_report/report/abstract_report_xlsx.py

@ -41,7 +41,7 @@ class AbstractReportXslx(models.AbstractModel):
self._define_formats(workbook) self._define_formats(workbook)
report_name = self._get_report_name(objects)
report_name = self._get_report_name(report)
report_footer = self._get_report_footer() report_footer = self._get_report_footer()
filters = self._get_report_filters(report) filters = self._get_report_filters(report)
self.columns = self._get_report_columns(report) self.columns = self._get_report_columns(report)
@ -349,7 +349,7 @@ class AbstractReportXslx(models.AbstractModel):
""" """
raise NotImplementedError() raise NotImplementedError()
def _get_report_name(self, objects):
def _get_report_name(self, report):
""" """
Allow to define the report name. Allow to define the report name.
Report name will be used as sheet name and as report title. Report name will be used as sheet name and as report title.

3
account_financial_report/report/aged_partner_balance_xlsx.py

@ -10,8 +10,7 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
_name = 'report.a_f_r.report_aged_partner_balance_xlsx' _name = 'report.a_f_r.report_aged_partner_balance_xlsx'
_inherit = 'report.account_financial_report.abstract_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 _('Aged Partner Balance - %s - %s') % ( return _('Aged Partner Balance - %s - %s') % (
report.company_id.name, report.company_id.currency_id.name) report.company_id.name, report.company_id.currency_id.name)

3
account_financial_report/report/general_ledger_xlsx.py

@ -11,8 +11,7 @@ class GeneralLedgerXslx(models.AbstractModel):
_name = 'report.a_f_r.report_general_ledger_xlsx' _name = 'report.a_f_r.report_general_ledger_xlsx'
_inherit = 'report.account_financial_report.abstract_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 _('General Ledger - %s - %s') % ( return _('General Ledger - %s - %s') % (
report.company_id.name, report.company_id.currency_id.name) report.company_id.name, report.company_id.currency_id.name)

3
account_financial_report/report/journal_ledger_xlsx.py

@ -10,8 +10,7 @@ class JournalLedgerXslx(models.AbstractModel):
_name = 'report.a_f_r.report_journal_ledger_xlsx' _name = 'report.a_f_r.report_journal_ledger_xlsx'
_inherit = 'report.account_financial_report.abstract_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 _('Journal Ledger - %s - %s') % ( return _('Journal Ledger - %s - %s') % (
report.company_id.name, report.company_id.currency_id.name) report.company_id.name, report.company_id.currency_id.name)

3
account_financial_report/report/open_items_xlsx.py

@ -9,8 +9,7 @@ class OpenItemsXslx(models.AbstractModel):
_name = 'report.a_f_r.report_open_items_xlsx' _name = 'report.a_f_r.report_open_items_xlsx'
_inherit = 'report.account_financial_report.abstract_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 _('Open Items - %s - %s') % ( return _('Open Items - %s - %s') % (
report.company_id.name, report.company_id.currency_id.name) report.company_id.name, report.company_id.currency_id.name)

3
account_financial_report/report/trial_balance_xlsx.py

@ -10,8 +10,7 @@ class TrialBalanceXslx(models.AbstractModel):
_name = 'report.a_f_r.report_trial_balance_xlsx' _name = 'report.a_f_r.report_trial_balance_xlsx'
_inherit = 'report.account_financial_report.abstract_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 _('Trial Balance - %s - %s') % ( return _('Trial Balance - %s - %s') % (
report.company_id.name, report.company_id.currency_id.name) report.company_id.name, report.company_id.currency_id.name)

3
account_financial_report/report/vat_report_xlsx.py

@ -8,8 +8,7 @@ class VATReportXslx(models.AbstractModel):
_name = 'report.a_f_r.report_vat_report_xlsx' _name = 'report.a_f_r.report_vat_report_xlsx'
_inherit = 'report.account_financial_report.abstract_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') % ( return _('VAT Report - %s - %s') % (
report.company_id.name, report.company_id.currency_id.name) report.company_id.name, report.company_id.currency_id.name)

7
account_financial_report/wizard/general_ledger_wizard.py

@ -103,6 +103,10 @@ class GeneralLedgerReportWizard(models.TransientModel):
if self.company_id and self.date_range_id.company_id and \ 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.company_id != self.company_id:
self.date_range_id = False 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: if self.company_id and self.partner_ids:
self.partner_ids = self.partner_ids.filtered( self.partner_ids = self.partner_ids.filtered(
lambda p: p.company_id == self.company_id or 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) lambda c: c.company_id == self.company_id)
res = {'domain': {'account_ids': [], res = {'domain': {'account_ids': [],
'partner_ids': [], 'partner_ids': [],
'account_journal_ids': [],
'cost_center_ids': [], 'cost_center_ids': [],
'date_range_id': [] 'date_range_id': []
} }
@ -127,6 +132,8 @@ class GeneralLedgerReportWizard(models.TransientModel):
else: else:
res['domain']['account_ids'] += [ res['domain']['account_ids'] += [
('company_id', '=', self.company_id.id)] ('company_id', '=', self.company_id.id)]
res['domain']['account_journal_ids'] += [
('company_id', '=', self.company_id.id)]
res['domain']['partner_ids'] += [ res['domain']['partner_ids'] += [
'|', ('company_id', '=', self.company_id.id), '|', ('company_id', '=', self.company_id.id),
('company_id', '=', False)] ('company_id', '=', False)]

Loading…
Cancel
Save