Browse Source
Merge pull request #352 from hbrunn/8.0-add-aged_partner_balance_xls
Merge pull request #352 from hbrunn/8.0-add-aged_partner_balance_xls
[8.0] [account_financial_report_webkit_xls] add aged partner balance & aged open invoices xlspull/370/merge
Stefan Rijnhart (Opener)
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
99 changed files with 1727 additions and 1235 deletions
-
69account_financial_report/report/parser.py
-
32account_financial_report/wizard/wizard.py
-
1account_financial_report_webkit/README.rst
-
2account_financial_report_webkit/__init__.py
-
4account_financial_report_webkit/__openerp__.py
-
2account_financial_report_webkit/data/financial_webkit_header.xml
-
35account_financial_report_webkit/hooks.py
-
22account_financial_report_webkit/models/account.py
-
1account_financial_report_webkit/models/account_move_line.py
-
1account_financial_report_webkit/report/aged_open_invoices.py
-
1account_financial_report_webkit/report/aged_partner_balance.py
-
2account_financial_report_webkit/report/common_balance_reports.py
-
2account_financial_report_webkit/report/common_partner_balance_reports.py
-
2account_financial_report_webkit/report/common_partner_reports.py
-
12account_financial_report_webkit/report/common_reports.py
-
3account_financial_report_webkit/report/general_ledger.py
-
14account_financial_report_webkit/report/open_invoices.py
-
4account_financial_report_webkit/report/partner_balance.py
-
7account_financial_report_webkit/report/partners_ledger.py
-
3account_financial_report_webkit/report/print_journal.py
-
3account_financial_report_webkit/report/trial_balance.py
-
3account_financial_report_webkit/report/webkit_parser_header_fix.py
-
11account_financial_report_webkit/tests/__init__.py
-
24account_financial_report_webkit/tests/test_aged_open_invoices.py
-
26account_financial_report_webkit/tests/test_aged_partner_balance.py
-
44account_financial_report_webkit/tests/test_common.py
-
23account_financial_report_webkit/tests/test_general_leger.py
-
27account_financial_report_webkit/tests/test_journal.py
-
24account_financial_report_webkit/tests/test_open_invoices.py
-
23account_financial_report_webkit/tests/test_partner_balance.py
-
23account_financial_report_webkit/tests/test_partner_ledger.py
-
23account_financial_report_webkit/tests/test_trial_balance.py
-
23account_financial_report_webkit/wizard/__init__.py
-
12account_financial_report_webkit/wizard/aged_open_invoices_wizard.py
-
1account_financial_report_webkit/wizard/aged_open_invoices_wizard.xml
-
74account_financial_report_webkit/wizard/aged_partner_balance_wizard.py
-
1account_financial_report_webkit/wizard/aged_partner_balance_wizard.xml
-
78account_financial_report_webkit/wizard/balance_common.py
-
54account_financial_report_webkit/wizard/general_ledger_wizard.py
-
1account_financial_report_webkit/wizard/general_ledger_wizard_view.xml
-
28account_financial_report_webkit/wizard/open_invoices_wizard.py
-
1account_financial_report_webkit/wizard/open_invoices_wizard_view.xml
-
1account_financial_report_webkit/wizard/partner_balance_wizard.py
-
1account_financial_report_webkit/wizard/partner_balance_wizard_view.xml
-
48account_financial_report_webkit/wizard/partners_ledger_wizard.py
-
1account_financial_report_webkit/wizard/partners_ledger_wizard_view.xml
-
24account_financial_report_webkit/wizard/print_journal.py
-
1account_financial_report_webkit/wizard/print_journal_view.xml
-
8account_financial_report_webkit/wizard/trial_balance_wizard.py
-
1account_financial_report_webkit/wizard/trial_balance_wizard_view.xml
-
64account_financial_report_webkit_xls/README.rst
-
23account_financial_report_webkit_xls/__init__.py
-
49account_financial_report_webkit_xls/__openerp__.py
-
2account_financial_report_webkit_xls/report/__init__.py
-
281account_financial_report_webkit_xls/report/aged_open_invoices_xls.py
-
281account_financial_report_webkit_xls/report/aged_partner_balance_xls.py
-
8account_financial_report_webkit_xls/report/general_ledger_xls.py
-
6account_financial_report_webkit_xls/report/open_invoices_xls.py
-
8account_financial_report_webkit_xls/report/partner_ledger_xls.py
-
8account_financial_report_webkit_xls/report/partners_balance_xls.py
-
29account_financial_report_webkit_xls/report/trial_balance_xls.py
-
556account_financial_report_webkit_xls/static/description/icon.svg
-
0account_financial_report_webkit_xls/test/general_ledger.yml
-
0account_financial_report_webkit_xls/test/open_invoices.yml
-
0account_financial_report_webkit_xls/test/partner_balance.yml
-
0account_financial_report_webkit_xls/test/partner_ledger.yml
-
0account_financial_report_webkit_xls/test/trial_balance.yml
-
8account_financial_report_webkit_xls/tests/__init__.py
-
33account_financial_report_webkit_xls/tests/test_aged_open_invoices_xls.py
-
31account_financial_report_webkit_xls/tests/test_aged_partner_balance_xls.py
-
60account_financial_report_webkit_xls/tests/test_common_xls.py
-
28account_financial_report_webkit_xls/tests/test_general_leger_xls.py
-
29account_financial_report_webkit_xls/tests/test_open_invoices_xls.py
-
28account_financial_report_webkit_xls/tests/test_partner_balance_xls.py
-
28account_financial_report_webkit_xls/tests/test_partner_ledger_xls.py
-
28account_financial_report_webkit_xls/tests/test_trial_balance_xls.py
-
25account_financial_report_webkit_xls/wizard/__init__.py
-
27account_financial_report_webkit_xls/wizard/aged_open_invoices_wizard.py
-
17account_financial_report_webkit_xls/wizard/aged_open_invoices_wizard.xml
-
27account_financial_report_webkit_xls/wizard/aged_partner_balance_wizard.py
-
18account_financial_report_webkit_xls/wizard/aged_partner_balance_wizard.xml
-
35account_financial_report_webkit_xls/wizard/general_ledger_wizard.py
-
20account_financial_report_webkit_xls/wizard/general_ledger_wizard_view.xml
-
35account_financial_report_webkit_xls/wizard/open_invoices_wizard.py
-
20account_financial_report_webkit_xls/wizard/open_invoices_wizard_view.xml
-
35account_financial_report_webkit_xls/wizard/partners_balance_wizard.py
-
18account_financial_report_webkit_xls/wizard/partners_balance_wizard_view.xml
-
43account_financial_report_webkit_xls/wizard/partners_ledger_wizard.py
-
20account_financial_report_webkit_xls/wizard/partners_ledger_wizard_view.xml
-
35account_financial_report_webkit_xls/wizard/trial_balance_wizard.py
-
22account_financial_report_webkit_xls/wizard/trial_balance_wizard_view.xml
-
2account_journal_report_xls/__init__.py
-
2account_journal_report_xls/__openerp__.py
-
11account_journal_report_xls/account_journal.py
-
16account_journal_report_xls/report/nov_account_journal.py
-
34account_journal_report_xls/report/nov_account_journal_xls.py
-
23account_journal_report_xls/wizard/__init__.py
-
48account_journal_report_xls/wizard/print_journal_wizard.py
-
10account_journal_report_xls/wizard/print_journal_wizard.xml
@ -0,0 +1,35 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2017 Therp BV <http://therp.nl> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
from .models.account_move_line import AccountMoveLine |
|||
|
|||
|
|||
def pre_init_hook(cr): |
|||
with cr.savepoint(): |
|||
# don't break if column exists |
|||
cr.execute( |
|||
'alter table account_move_line add column last_rec_date date', |
|||
) |
|||
cr.execute( |
|||
'comment on column account_move_line.last_rec_date is %s', |
|||
(AccountMoveLine.last_rec_date.string,), |
|||
) |
|||
cr.execute( |
|||
'create index account_move_line_last_rec_date_index ' |
|||
'on account_move_line (last_rec_date)', |
|||
) |
|||
# but still do the initialization |
|||
cr.execute( |
|||
"""update account_move_line |
|||
set last_rec_date=ml_fr.date |
|||
from account_move_line ml |
|||
left join account_move_reconcile fr on ml.reconcile_id=fr.id |
|||
join ( |
|||
select |
|||
coalesce(reconcile_id, reconcile_partial_id) as reconcile_id, |
|||
max(date) as date |
|||
from account_move_line |
|||
group by coalesce(reconcile_id, reconcile_partial_id) |
|||
) ml_fr on ml_fr.reconcile_id=fr.id |
|||
where ml.id=account_move_line.id""" |
|||
) |
@ -1,5 +1,10 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Savoir-faire Linux |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from . import test_account_move_line |
|||
from . import test_general_leger |
|||
from . import test_partner_ledger |
|||
from . import test_trial_balance |
|||
from . import test_partner_balance |
|||
from . import test_open_invoices |
|||
from . import test_aged_open_invoices |
|||
from . import test_aged_partner_balance |
|||
from . import test_journal |
@ -0,0 +1,24 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009-2017 Noviat. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from datetime import datetime |
|||
from .test_common import TestCommon |
|||
|
|||
|
|||
class TestOpenInvoices(TestCommon): |
|||
|
|||
def _getReportModel(self): |
|||
return 'aged.open.invoices.webkit' |
|||
|
|||
def _getReportName(self): |
|||
return 'account.account_aged_open_invoices_webkit' |
|||
|
|||
def _getBaseFilters(self): |
|||
return {'until_date': '%s-12-31' % (datetime.now().year)} |
|||
|
|||
def test_common(self): |
|||
common_tests = [ |
|||
x for x in dir(self) |
|||
if callable(getattr(self, x)) and x.startswith('common_test_')] |
|||
for test in common_tests: |
|||
getattr(self, test)() |
@ -0,0 +1,26 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009-2017 Noviat. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from .test_common import TestCommon |
|||
|
|||
|
|||
class TestAgedPartnerBalance(TestCommon): |
|||
|
|||
def _getReportModel(self): |
|||
return 'account.aged.trial.balance.webkit' |
|||
|
|||
def _getReportName(self): |
|||
return 'account.account_aged_trial_balance_webkit' |
|||
|
|||
def _getBaseFilters(self): |
|||
fy_id = self.model._get_current_fiscalyear() |
|||
vals = self.model.onchange_fiscalyear(fiscalyear=fy_id)['value'] |
|||
vals.update({'fiscalyear_id': fy_id}) |
|||
return vals |
|||
|
|||
def test_common(self): |
|||
common_tests = [ |
|||
x for x in dir(self) |
|||
if callable(getattr(self, x)) and x.startswith('common_test_')] |
|||
for test in common_tests: |
|||
getattr(self, test)() |
@ -0,0 +1,44 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009-2017 Noviat. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from openerp.tests.common import TransactionCase |
|||
|
|||
|
|||
class TestCommon(TransactionCase): |
|||
""" Common tests for all reports """ |
|||
|
|||
def setUp(self): |
|||
super(TestCommon, self).setUp() |
|||
self.model = self.env[self._getReportModel()] |
|||
self.report_name = self._getReportName() |
|||
wiz_vals = {'chart_account_id': self.env.ref('account.chart0').id} |
|||
wiz_vals.update(self._getBaseFilters()) |
|||
self.report = self.model.create(wiz_vals) |
|||
|
|||
def common_test_01_generation_report(self): |
|||
""" Check if report is correctly generated """ |
|||
|
|||
# Check if returned report action is correct |
|||
report_action = self.report.check_report() |
|||
self.assertDictContainsSubset( |
|||
{'type': 'ir.actions.report.xml', |
|||
'report_name': self.report_name}, |
|||
report_action) |
|||
|
|||
def _getReportModel(self): |
|||
""" |
|||
:return: the report model name |
|||
""" |
|||
raise NotImplementedError() |
|||
|
|||
def _getReportName(self): |
|||
""" |
|||
:return: the xls report name |
|||
""" |
|||
raise NotImplementedError() |
|||
|
|||
def _getBaseFilters(self): |
|||
""" |
|||
:return: the minimum required filters to generate report |
|||
""" |
|||
raise NotImplementedError() |
@ -0,0 +1,23 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009-2017 Noviat. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from .test_common import TestCommon |
|||
|
|||
|
|||
class TestGeneralLedger(TestCommon): |
|||
|
|||
def _getReportModel(self): |
|||
return 'general.ledger.webkit' |
|||
|
|||
def _getReportName(self): |
|||
return 'account.account_report_general_ledger_webkit' |
|||
|
|||
def _getBaseFilters(self): |
|||
return {} |
|||
|
|||
def test_common(self): |
|||
common_tests = [ |
|||
x for x in dir(self) |
|||
if callable(getattr(self, x)) and x.startswith('common_test_')] |
|||
for test in common_tests: |
|||
getattr(self, test)() |
@ -0,0 +1,27 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009-2017 Noviat. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from .test_common import TestCommon |
|||
|
|||
|
|||
class TestGeneralLedger(TestCommon): |
|||
|
|||
def _getReportModel(self): |
|||
return 'print.journal.webkit' |
|||
|
|||
def _getReportName(self): |
|||
return 'account.account_report_print_journal_webkit' |
|||
|
|||
def _getBaseFilters(self): |
|||
fy_id = self.model._get_fiscalyear() |
|||
vals = self.model.onchange_filter( |
|||
filter='filter_period', fiscalyear_id=fy_id)['value'] |
|||
vals.update({'fiscalyear_id': fy_id}) |
|||
return vals |
|||
|
|||
def test_common(self): |
|||
common_tests = [ |
|||
x for x in dir(self) |
|||
if callable(getattr(self, x)) and x.startswith('common_test_')] |
|||
for test in common_tests: |
|||
getattr(self, test)() |
@ -0,0 +1,24 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009-2017 Noviat. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from datetime import datetime |
|||
from .test_common import TestCommon |
|||
|
|||
|
|||
class TestOpenInvoices(TestCommon): |
|||
|
|||
def _getReportModel(self): |
|||
return 'open.invoices.webkit' |
|||
|
|||
def _getReportName(self): |
|||
return 'account.account_report_open_invoices_webkit' |
|||
|
|||
def _getBaseFilters(self): |
|||
return {'until_date': '%s-12-31' % (datetime.now().year)} |
|||
|
|||
def test_common(self): |
|||
common_tests = [ |
|||
x for x in dir(self) |
|||
if callable(getattr(self, x)) and x.startswith('common_test_')] |
|||
for test in common_tests: |
|||
getattr(self, test)() |
@ -0,0 +1,23 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009-2017 Noviat. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from .test_common import TestCommon |
|||
|
|||
|
|||
class TestPartnerBalance(TestCommon): |
|||
|
|||
def _getReportModel(self): |
|||
return 'partner.balance.webkit' |
|||
|
|||
def _getReportName(self): |
|||
return 'account.account_report_partner_balance_webkit' |
|||
|
|||
def _getBaseFilters(self): |
|||
return {} |
|||
|
|||
def test_common(self): |
|||
common_tests = [ |
|||
x for x in dir(self) |
|||
if callable(getattr(self, x)) and x.startswith('common_test_')] |
|||
for test in common_tests: |
|||
getattr(self, test)() |
@ -0,0 +1,23 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009-2017 Noviat. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from .test_common import TestCommon |
|||
|
|||
|
|||
class TestPartnerLedger(TestCommon): |
|||
|
|||
def _getReportModel(self): |
|||
return 'partners.ledger.webkit' |
|||
|
|||
def _getReportName(self): |
|||
return 'account.account_report_partners_ledger_webkit' |
|||
|
|||
def _getBaseFilters(self): |
|||
return {} |
|||
|
|||
def test_common(self): |
|||
common_tests = [ |
|||
x for x in dir(self) |
|||
if callable(getattr(self, x)) and x.startswith('common_test_')] |
|||
for test in common_tests: |
|||
getattr(self, test)() |
@ -0,0 +1,23 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009-2017 Noviat. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from .test_common import TestCommon |
|||
|
|||
|
|||
class TestTrialBalance(TestCommon): |
|||
|
|||
def _getReportModel(self): |
|||
return 'trial.balance.webkit' |
|||
|
|||
def _getReportName(self): |
|||
return 'account.account_report_trial_balance_webkit' |
|||
|
|||
def _getBaseFilters(self): |
|||
return {} |
|||
|
|||
def test_common(self): |
|||
common_tests = [ |
|||
x for x in dir(self) |
|||
if callable(getattr(self, x)) and x.startswith('common_test_')] |
|||
for test in common_tests: |
|||
getattr(self, test)() |
@ -0,0 +1,64 @@ |
|||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg |
|||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html |
|||
:alt: License: AGPL-3 |
|||
|
|||
============================== |
|||
Financial Reports - XLS Export |
|||
============================== |
|||
|
|||
This module adds XLS export to the following accounting reports: |
|||
- General Ledger |
|||
- Trial Balance |
|||
- Partner Ledger |
|||
- Partner Balance |
|||
- Aged Partner Balance |
|||
- Open Invoices |
|||
|
|||
Installation |
|||
============ |
|||
|
|||
To install this module, you need also the **report_xls** |
|||
module located in: |
|||
|
|||
https://github.com/OCA/reporting-engine |
|||
|
|||
Usage |
|||
===== |
|||
|
|||
Use the 'Export' button on the financial report wizards to export the |
|||
data in Excel format. |
|||
|
|||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas |
|||
:alt: Try me on Runbot |
|||
:target: https://runbot.odoo-community.org/runbot/91/8.0 |
|||
|
|||
Bug Tracker |
|||
=========== |
|||
|
|||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-reporting/issues>`_. |
|||
In case of trouble, please |
|||
check there if your issue has already been reported. If you spotted it first, |
|||
help us smash it by providing detailed and welcomed feedback. |
|||
|
|||
Credits |
|||
======= |
|||
|
|||
Contributors |
|||
------------ |
|||
|
|||
* Noviat <info@noviat.com> |
|||
|
|||
Maintainer |
|||
---------- |
|||
|
|||
.. image:: https://odoo-community.org/logo.png |
|||
:alt: Odoo Community Association |
|||
:target: https://odoo-community.org |
|||
|
|||
This module is maintained by the OCA. |
|||
|
|||
OCA, or the Odoo Community Association, is a nonprofit organization whose |
|||
mission is to support the collaborative development of Odoo features and |
|||
promote its widespread use. |
|||
|
|||
To contribute to this module, please visit https://odoo-community.org. |
@ -0,0 +1,281 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009-2016 Noviat. |
|||
# Copyright 2017 Therp BV. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
import xlwt |
|||
from openerp.addons.report_xls.report_xls import report_xls |
|||
from openerp.addons.report_xls.utils import rowcol_to_cell |
|||
from openerp.addons.account_financial_report_webkit.report \ |
|||
.aged_open_invoices import AccountAgedOpenInvoicesWebkit |
|||
from openerp.tools.translate import _ |
|||
# import logging |
|||
# _logger = logging.getLogger(__name__) |
|||
|
|||
|
|||
class AccountAgedOpenInvoicesWebkitXls(report_xls): |
|||
|
|||
# pylint: disable=old-api7-method-defined |
|||
def create(self, cr, uid, ids, data, context=None): |
|||
self._column_sizes = [ |
|||
30, # Partner |
|||
20, # Partner Code |
|||
20, # Balance |
|||
20, # Due |
|||
20, # Overdue 0-30 |
|||
20, # Overdue 30-60 |
|||
20, # Overdue 60-90 |
|||
20, # Overdue 90-120 |
|||
20, # Overdue 120+ |
|||
] |
|||
self._balance_pos = 2 |
|||
return super(AccountAgedOpenInvoicesWebkitXls, self).create( |
|||
cr, uid, ids, data, context=context) |
|||
|
|||
def _cell_styles(self, _xs): |
|||
self._style_title = xlwt.easyxf(_xs['xls_title']) |
|||
self._style_bold_blue_center = xlwt.easyxf( |
|||
_xs['bold'] + _xs['fill_blue'] + _xs['borders_all'] + |
|||
_xs['center']) |
|||
self._style_center = xlwt.easyxf( |
|||
_xs['borders_all'] + _xs['wrap'] + _xs['center']) |
|||
|
|||
format_yellow_bold = _xs['bold'] + _xs['fill'] + _xs['borders_all'] |
|||
self._style_account_title = xlwt.easyxf( |
|||
format_yellow_bold + _xs['xls_title']) |
|||
self._style_yellow_bold = xlwt.easyxf(format_yellow_bold) |
|||
self._style_yellow_bold_right = xlwt.easyxf( |
|||
format_yellow_bold + _xs['right']) |
|||
self._style_yellow_bold_decimal = xlwt.easyxf( |
|||
format_yellow_bold + _xs['right'], |
|||
num_format_str=report_xls.decimal_format) |
|||
|
|||
self._style_default = xlwt.easyxf(_xs['borders_all']) |
|||
self._style_decimal = xlwt.easyxf( |
|||
_xs['borders_all'] + _xs['right'], |
|||
num_format_str=report_xls.decimal_format) |
|||
self._style_percent = xlwt.easyxf( |
|||
_xs['borders_all'] + _xs['right'], |
|||
num_format_str='0.00%') |
|||
|
|||
def _setup_worksheet(self, _p, _xs, data, wb): |
|||
self.ws = wb.add_sheet(_p.report_name[:31]) |
|||
self.ws.panes_frozen = True |
|||
self.ws.remove_splits = True |
|||
self.ws.portrait = 0 # Landscape |
|||
self.ws.fit_width_to_pages = 1 |
|||
self.ws.header_str = self.xls_headers['standard'] |
|||
self.ws.footer_str = self.xls_footers['standard'] |
|||
|
|||
def _print_title(self, _p, _xs, data, row_pos): |
|||
report_name = ' - '.join( |
|||
[_p.report_name.upper(), |
|||
_p.company.partner_id.name, |
|||
_p.company.currency_id.name]) |
|||
c_specs = [ |
|||
('report_name', 1, 0, 'text', report_name), |
|||
] |
|||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) |
|||
row_pos = self.xls_write_row( |
|||
self.ws, row_pos, row_data, row_style=self._style_title) |
|||
return row_pos |
|||
|
|||
def _print_empty_row(self, _p, _xs, data, row_pos): |
|||
""" |
|||
Print empty row to define column sizes |
|||
""" |
|||
c_specs = [('empty%s' % i, 1, self._column_sizes[i], 'text', None) |
|||
for i in range(len(self._column_sizes))] |
|||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) |
|||
row_pos = self.xls_write_row( |
|||
self.ws, row_pos, row_data, set_column_size=True) |
|||
return row_pos |
|||
|
|||
def _print_header_title(self, _p, _xs, data, row_pos): |
|||
c_specs = [ |
|||
('coa', 1, 0, 'text', _('Chart of Account')), |
|||
('fy', 1, 0, 'text', _('Fiscal Year')), |
|||
('period_filter', 2, 0, 'text', _('Periods Filter')), |
|||
('cd', 1, 0, 'text', _('Clearance Date')), |
|||
('account_filter', 2, 0, 'text', _('Accounts Filter')), |
|||
('partner_filter', 1, 0, 'text', _('Partners Filter')), |
|||
('tm', 1, 0, 'text', _('Target Moves')), |
|||
] |
|||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) |
|||
row_pos = self.xls_write_row( |
|||
self.ws, row_pos, row_data, |
|||
row_style=self._style_bold_blue_center) |
|||
return row_pos |
|||
|
|||
def _print_header_data(self, _p, _xs, data, row_pos): |
|||
period_filter = _('From') + ': ' |
|||
period_filter += _p.start_period.name if _p.start_period else u'' |
|||
period_filter += ' ' + _('To') + ': ' |
|||
period_filter += _p.stop_period.name if _p.stop_period else u'' |
|||
c_specs = [ |
|||
('coa', 1, 0, 'text', _p.chart_account.name), |
|||
('fy', 1, 0, 'text', |
|||
_p.fiscalyear.name if _p.fiscalyear else '-'), |
|||
('period_filter', 2, 0, 'text', period_filter), |
|||
('cd', 1, 0, 'text', _p.date_until), |
|||
('account_filter', 2, 0, 'text', |
|||
_p.display_partner_account(data)), |
|||
('partner_filter', 1, 0, 'text', |
|||
_('Selected Partners') if _p.partner_ids else '-'), |
|||
('tm', 1, 0, 'text', |
|||
_p.display_target_move(data)), |
|||
] |
|||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) |
|||
row_pos = self.xls_write_row( |
|||
self.ws, row_pos, row_data, row_style=self._style_center) |
|||
return row_pos |
|||
|
|||
def _print_header(self, _p, _xs, data, row_pos): |
|||
""" |
|||
Header Table: Chart of Account, Fiscal year, Filters, ... |
|||
""" |
|||
row_pos = self._print_header_title(_p, _xs, data, row_pos) |
|||
row_pos = self._print_header_data(_p, _xs, data, row_pos) |
|||
self.ws.set_horz_split_pos(row_pos) # freeze the line |
|||
return row_pos + 1 |
|||
|
|||
def _print_account_header(self, _p, _xs, data, row_pos, account): |
|||
""" |
|||
Fill in a row with the code and name of the account |
|||
""" |
|||
c_specs = [ |
|||
('acc_title', len(self._column_sizes), 0, 'text', |
|||
' - '.join([account.code, account.name])), |
|||
] |
|||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) |
|||
row_pos = self.xls_write_row( |
|||
self.ws, row_pos, row_data, self._style_account_title) |
|||
return row_pos + 1 |
|||
|
|||
def _print_partner_header(self, _p, _xs, data, row_pos): |
|||
""" |
|||
Partner header line |
|||
""" |
|||
c_specs = [ |
|||
('partner_h', 1, 0, 'text', _('Partner'), |
|||
None, self._style_yellow_bold), |
|||
('pcode_h', 1, 0, 'text', _('Code'), |
|||
None, self._style_yellow_bold), |
|||
('balance_h', 1, 0, 'text', _('Balance')), |
|||
('due_h', 1, 0, 'text', _('Due'))] |
|||
for days in [30, 60, 90, 120]: |
|||
entry = 'od_%s_h' % days |
|||
label = _("Overdue ≤ %s d.") % days |
|||
c_specs += [(entry, 1, 0, 'text', label)] |
|||
c_specs += [('older_h', 1, 0, 'text', _("Older"))] |
|||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) |
|||
row_pos = self.xls_write_row( |
|||
self.ws, row_pos, row_data, |
|||
row_style=self._style_yellow_bold_right) |
|||
return row_pos |
|||
|
|||
def _print_partner_line(self, _p, _xs, data, row_pos, partner, line): |
|||
""" |
|||
Partner data line |
|||
""" |
|||
partner_name, p_id, p_ref, p_name = partner |
|||
c_specs = [ |
|||
('partner', 1, 0, 'text', p_name, |
|||
None, self._style_default), |
|||
('pcode', 1, 0, 'text', p_ref, |
|||
None, self._style_default), |
|||
('balance', 1, 0, 'number', line['balance'])] |
|||
for r in _p.ranges: |
|||
entry = 'od_%s' % r[0] |
|||
c_specs += [(entry, 1, 0, 'number', line[r])] |
|||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) |
|||
row_pos = self.xls_write_row( |
|||
self.ws, row_pos, row_data, |
|||
row_style=self._style_decimal) |
|||
return row_pos |
|||
|
|||
def _print_partner_footer(self, _p, _xs, data, row_pos, |
|||
account, line_count): |
|||
""" |
|||
Partner header line |
|||
""" |
|||
# Totals |
|||
c_specs = [ |
|||
('total', 1, 0, 'text', _('Total') + ' ' + account.code, |
|||
None, self._style_yellow_bold), |
|||
('empty', 1, 0, 'text', None, |
|||
None, self._style_yellow_bold)] |
|||
row_start = row_pos - line_count |
|||
col_start = self._balance_pos |
|||
start = rowcol_to_cell(row_start, col_start) |
|||
stop = rowcol_to_cell(row_pos - 1, col_start) |
|||
formula = 'SUM(%s:%s)' % (start, stop) |
|||
c_specs += [('total_balance', 1, 0, 'number', None, formula)] |
|||
col_start += 1 |
|||
for i, r in enumerate(_p.ranges): |
|||
entry = 'total_%s' % i |
|||
start = rowcol_to_cell(row_start, col_start + i) |
|||
stop = rowcol_to_cell(row_pos - 1, col_start + i) |
|||
formula = 'SUM(%s:%s)' % (start, stop) |
|||
c_specs += [(entry, 1, 0, 'number', None, formula)] |
|||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) |
|||
row_pos = self.xls_write_row( |
|||
self.ws, row_pos, row_data, |
|||
row_style=self._style_yellow_bold_decimal) |
|||
|
|||
# percents |
|||
c_specs = [ |
|||
('pct', 1, 0, 'text', _('Percentages') + ' ' + account.code, |
|||
None, self._style_default), |
|||
('empty', 2, 0, 'text', None, |
|||
None, self._style_default)] |
|||
total_balance = rowcol_to_cell(row_pos - 1, self._balance_pos) |
|||
for i, r in enumerate(_p.ranges): |
|||
entry = 'pct_%s' % i |
|||
total_range = rowcol_to_cell(row_pos - 1, col_start + i) |
|||
formula = '%s/%s' % (total_range, total_balance) |
|||
c_specs += [(entry, 1, 0, 'number', None, formula)] |
|||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) |
|||
row_pos = self.xls_write_row( |
|||
self.ws, row_pos, row_data, |
|||
row_style=self._style_percent) |
|||
|
|||
return row_pos |
|||
|
|||
def _print_account_data(self, _p, _xs, data, row_pos, account): |
|||
if _p.aged_open_inv[account.id]: |
|||
row_pos = self._print_account_header( |
|||
_p, _xs, data, row_pos, account) |
|||
lines = _p.aged_open_inv[account.id] |
|||
|
|||
row_pos = self._print_partner_header( |
|||
_p, _xs, data, row_pos) |
|||
row_pos_start = row_pos |
|||
for partner in _p.partners_order[account.id]: |
|||
partner_id = partner[1] |
|||
if partner_id in lines: |
|||
line = lines[partner_id] |
|||
row_pos = self._print_partner_line( |
|||
_p, _xs, data, row_pos, partner, line) |
|||
line_count = row_pos - row_pos_start |
|||
row_pos = self._print_partner_footer( |
|||
_p, _xs, data, row_pos, account, line_count) |
|||
return row_pos + 1 |
|||
|
|||
def generate_xls_report(self, _p, _xs, data, objects, wb): |
|||
self._cell_styles(_xs) |
|||
self._setup_worksheet(_p, _xs, data, wb) |
|||
|
|||
row_pos = 0 |
|||
row_pos = self._print_title(_p, _xs, data, row_pos) |
|||
row_pos = self._print_empty_row(_p, _xs, data, row_pos) |
|||
row_pos = self._print_header(_p, _xs, data, row_pos) |
|||
|
|||
for account in objects: |
|||
row_pos = self._print_account_data( |
|||
_p, _xs, data, row_pos, account) |
|||
|
|||
|
|||
AccountAgedOpenInvoicesWebkitXls( |
|||
'report.account.aged_open_invoices_xls', |
|||
'account.account', |
|||
parser=AccountAgedOpenInvoicesWebkit) |
@ -0,0 +1,281 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009-2016 Noviat. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
import xlwt |
|||
from openerp.addons.report_xls.report_xls import report_xls |
|||
from openerp.addons.report_xls.utils import rowcol_to_cell |
|||
from openerp.addons.account_financial_report_webkit.report \ |
|||
.aged_partner_balance import AccountAgedTrialBalanceWebkit |
|||
from openerp.tools.translate import _ |
|||
# import logging |
|||
# _logger = logging.getLogger(__name__) |
|||
|
|||
|
|||
class AccountAgedTrialBalanceWebkitXls(report_xls): |
|||
|
|||
# pylint: disable=old-api7-method-defined |
|||
def create(self, cr, uid, ids, data, context=None): |
|||
self._column_sizes = [ |
|||
30, # Partner |
|||
20, # Partner Code |
|||
20, # Balance |
|||
20, # Due |
|||
20, # Overdue 0-30 |
|||
20, # Overdue 30-60 |
|||
20, # Overdue 60-90 |
|||
20, # Overdue 90-120 |
|||
20, # Overdue 120+ |
|||
] |
|||
self._balance_pos = 2 |
|||
return super(AccountAgedTrialBalanceWebkitXls, self).create( |
|||
cr, uid, ids, data, context=context) |
|||
|
|||
def _cell_styles(self, _xs): |
|||
self._style_title = xlwt.easyxf(_xs['xls_title']) |
|||
self._style_bold_blue_center = xlwt.easyxf( |
|||
_xs['bold'] + _xs['fill_blue'] + _xs['borders_all'] + |
|||
_xs['center']) |
|||
self._style_center = xlwt.easyxf( |
|||
_xs['borders_all'] + _xs['wrap'] + _xs['center']) |
|||
|
|||
format_yellow_bold = _xs['bold'] + _xs['fill'] + _xs['borders_all'] |
|||
self._style_account_title = xlwt.easyxf( |
|||
format_yellow_bold + _xs['xls_title']) |
|||
self._style_yellow_bold = xlwt.easyxf(format_yellow_bold) |
|||
self._style_yellow_bold_right = xlwt.easyxf( |
|||
format_yellow_bold + _xs['right']) |
|||
self._style_yellow_bold_decimal = xlwt.easyxf( |
|||
format_yellow_bold + _xs['right'], |
|||
num_format_str=report_xls.decimal_format) |
|||
|
|||
self._style_default = xlwt.easyxf(_xs['borders_all']) |
|||
self._style_decimal = xlwt.easyxf( |
|||
_xs['borders_all'] + _xs['right'], |
|||
num_format_str=report_xls.decimal_format) |
|||
self._style_percent = xlwt.easyxf( |
|||
_xs['borders_all'] + _xs['right'], |
|||
num_format_str='0.00%') |
|||
|
|||
def _setup_worksheet(self, _p, _xs, data, wb): |
|||
self.ws = wb.add_sheet(_p.report_name[:31]) |
|||
self.ws.panes_frozen = True |
|||
self.ws.remove_splits = True |
|||
self.ws.portrait = 0 # Landscape |
|||
self.ws.fit_width_to_pages = 1 |
|||
self.ws.header_str = self.xls_headers['standard'] |
|||
self.ws.footer_str = self.xls_footers['standard'] |
|||
|
|||
def _print_title(self, _p, _xs, data, row_pos): |
|||
report_name = ' - '.join( |
|||
[_p.report_name.upper(), |
|||
_p.company.partner_id.name, |
|||
_p.company.currency_id.name]) |
|||
c_specs = [ |
|||
('report_name', 1, 0, 'text', report_name), |
|||
] |
|||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) |
|||
row_pos = self.xls_write_row( |
|||
self.ws, row_pos, row_data, row_style=self._style_title) |
|||
return row_pos |
|||
|
|||
def _print_empty_row(self, _p, _xs, data, row_pos): |
|||
""" |
|||
Print empty row to define column sizes |
|||
""" |
|||
c_specs = [('empty%s' % i, 1, self._column_sizes[i], 'text', None) |
|||
for i in range(len(self._column_sizes))] |
|||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) |
|||
row_pos = self.xls_write_row( |
|||
self.ws, row_pos, row_data, set_column_size=True) |
|||
return row_pos |
|||
|
|||
def _print_header_title(self, _p, _xs, data, row_pos): |
|||
c_specs = [ |
|||
('coa', 1, 0, 'text', _('Chart of Account')), |
|||
('fy', 1, 0, 'text', _('Fiscal Year')), |
|||
('period_filter', 2, 0, 'text', _('Periods Filter')), |
|||
('cd', 1, 0, 'text', _('Clearance Date')), |
|||
('account_filter', 2, 0, 'text', _('Accounts Filter')), |
|||
('partner_filter', 1, 0, 'text', _('Partners Filter')), |
|||
('tm', 1, 0, 'text', _('Target Moves')), |
|||
] |
|||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) |
|||
row_pos = self.xls_write_row( |
|||
self.ws, row_pos, row_data, |
|||
row_style=self._style_bold_blue_center) |
|||
return row_pos |
|||
|
|||
def _print_header_data(self, _p, _xs, data, row_pos): |
|||
period_filter = _('From') + ': ' |
|||
period_filter += _p.start_period.name if _p.start_period else u'' |
|||
period_filter += ' ' + _('To') + ': ' |
|||
period_filter += _p.stop_period.name if _p.stop_period else u'' |
|||
c_specs = [ |
|||
('coa', 1, 0, 'text', _p.chart_account.name), |
|||
('fy', 1, 0, 'text', |
|||
_p.fiscalyear.name if _p.fiscalyear else '-'), |
|||
('period_filter', 2, 0, 'text', period_filter), |
|||
('cd', 1, 0, 'text', _p.date_until), |
|||
('account_filter', 2, 0, 'text', |
|||
_p.display_partner_account(data)), |
|||
('partner_filter', 1, 0, 'text', |
|||
_('Selected Partners') if _p.partner_ids else '-'), |
|||
('tm', 1, 0, 'text', |
|||
_p.display_target_move(data)), |
|||
] |
|||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) |
|||
row_pos = self.xls_write_row( |
|||
self.ws, row_pos, row_data, row_style=self._style_center) |
|||
return row_pos |
|||
|
|||
def _print_header(self, _p, _xs, data, row_pos): |
|||
""" |
|||
Header Table: Chart of Account, Fiscal year, Filters, ... |
|||
""" |
|||
row_pos = self._print_header_title(_p, _xs, data, row_pos) |
|||
row_pos = self._print_header_data(_p, _xs, data, row_pos) |
|||
self.ws.set_horz_split_pos(row_pos) # freeze the line |
|||
return row_pos + 1 |
|||
|
|||
def _print_account_header(self, _p, _xs, data, row_pos, account): |
|||
""" |
|||
Fill in a row with the code and name of the account |
|||
""" |
|||
c_specs = [ |
|||
('acc_title', len(self._column_sizes), 0, 'text', |
|||
' - '.join([account.code, account.name])), |
|||
] |
|||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) |
|||
row_pos = self.xls_write_row( |
|||
self.ws, row_pos, row_data, self._style_account_title) |
|||
return row_pos + 1 |
|||
|
|||
def _print_partner_header(self, _p, _xs, data, row_pos): |
|||
""" |
|||
Partner header line |
|||
""" |
|||
c_specs = [ |
|||
('partner_h', 1, 0, 'text', _('Partner'), |
|||
None, self._style_yellow_bold), |
|||
('pcode_h', 1, 0, 'text', _('Code'), |
|||
None, self._style_yellow_bold), |
|||
('balance_h', 1, 0, 'text', _('Balance')), |
|||
('due_h', 1, 0, 'text', _('Due'))] |
|||
for days in [30, 60, 90, 120]: |
|||
entry = 'od_%s_h' % days |
|||
label = _("Overdue ≤ %s d.") % days |
|||
c_specs += [(entry, 1, 0, 'text', label)] |
|||
c_specs += [('older_h', 1, 0, 'text', _("Older"))] |
|||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) |
|||
row_pos = self.xls_write_row( |
|||
self.ws, row_pos, row_data, |
|||
row_style=self._style_yellow_bold_right) |
|||
return row_pos |
|||
|
|||
def _print_partner_line(self, _p, _xs, data, row_pos, partner, line): |
|||
""" |
|||
Partner data line |
|||
""" |
|||
partner_name, p_id, p_ref, p_name = partner |
|||
c_specs = [ |
|||
('partner', 1, 0, 'text', p_name, |
|||
None, self._style_default), |
|||
('pcode', 1, 0, 'text', p_ref, |
|||
None, self._style_default), |
|||
('balance', 1, 0, 'number', line['balance'])] |
|||
for r in _p.ranges: |
|||
entry = 'od_%s' % r[0] |
|||
c_specs += [(entry, 1, 0, 'number', line['aged_lines'][r])] |
|||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) |
|||
row_pos = self.xls_write_row( |
|||
self.ws, row_pos, row_data, |
|||
row_style=self._style_decimal) |
|||
return row_pos |
|||
|
|||
def _print_partner_footer(self, _p, _xs, data, row_pos, |
|||
account, line_count): |
|||
""" |
|||
Partner header line |
|||
""" |
|||
# Totals |
|||
c_specs = [ |
|||
('total', 1, 0, 'text', _('Total') + ' ' + account.code, |
|||
None, self._style_yellow_bold), |
|||
('empty', 1, 0, 'text', None, |
|||
None, self._style_yellow_bold)] |
|||
row_start = row_pos - line_count |
|||
col_start = self._balance_pos |
|||
start = rowcol_to_cell(row_start, col_start) |
|||
stop = rowcol_to_cell(row_pos - 1, col_start) |
|||
formula = 'SUM(%s:%s)' % (start, stop) |
|||
c_specs += [('total_balance', 1, 0, 'number', None, formula)] |
|||
col_start += 1 |
|||
for i, r in enumerate(_p.ranges): |
|||
entry = 'total_%s' % i |
|||
start = rowcol_to_cell(row_start, col_start + i) |
|||
stop = rowcol_to_cell(row_pos - 1, col_start + i) |
|||
formula = 'SUM(%s:%s)' % (start, stop) |
|||
c_specs += [(entry, 1, 0, 'number', None, formula)] |
|||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) |
|||
row_pos = self.xls_write_row( |
|||
self.ws, row_pos, row_data, |
|||
row_style=self._style_yellow_bold_decimal) |
|||
|
|||
# percents |
|||
c_specs = [ |
|||
('pct', 1, 0, 'text', _('Percentages') + ' ' + account.code, |
|||
None, self._style_default), |
|||
('empty', 2, 0, 'text', None, |
|||
None, self._style_default)] |
|||
total_balance = rowcol_to_cell(row_pos - 1, self._balance_pos) |
|||
for i, r in enumerate(_p.ranges): |
|||
entry = 'pct_%s' % i |
|||
total_range = rowcol_to_cell(row_pos - 1, col_start + i) |
|||
formula = '%s/%s' % (total_range, total_balance) |
|||
c_specs += [(entry, 1, 0, 'number', None, formula)] |
|||
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) |
|||
row_pos = self.xls_write_row( |
|||
self.ws, row_pos, row_data, |
|||
row_style=self._style_percent) |
|||
|
|||
return row_pos |
|||
|
|||
def _print_account_data(self, _p, _xs, data, row_pos, account): |
|||
if _p.agged_lines_accounts.get(account.id): |
|||
row_pos = self._print_account_header( |
|||
_p, _xs, data, row_pos, account) |
|||
lines = _p.agged_lines_accounts[account.id] |
|||
|
|||
row_pos = self._print_partner_header( |
|||
_p, _xs, data, row_pos) |
|||
row_pos_start = row_pos |
|||
for partner in _p.partners_order[account.id]: |
|||
partner_id = partner[1] |
|||
if partner_id in lines: |
|||
line = lines[partner_id] |
|||
row_pos = self._print_partner_line( |
|||
_p, _xs, data, row_pos, partner, line) |
|||
line_count = row_pos - row_pos_start |
|||
row_pos = self._print_partner_footer( |
|||
_p, _xs, data, row_pos, account, line_count) |
|||
return row_pos + 1 |
|||
|
|||
def generate_xls_report(self, _p, _xs, data, objects, wb): |
|||
|
|||
self._cell_styles(_xs) |
|||
self._setup_worksheet(_p, _xs, data, wb) |
|||
|
|||
row_pos = 0 |
|||
row_pos = self._print_title(_p, _xs, data, row_pos) |
|||
row_pos = self._print_empty_row(_p, _xs, data, row_pos) |
|||
row_pos = self._print_header(_p, _xs, data, row_pos) |
|||
|
|||
for account in objects: |
|||
row_pos = self._print_account_data( |
|||
_p, _xs, data, row_pos, account) |
|||
|
|||
|
|||
AccountAgedTrialBalanceWebkitXls( |
|||
'report.account.account_report_aged_partner_balance_xls', |
|||
'account.account', |
|||
parser=AccountAgedTrialBalanceWebkit) |
556
account_financial_report_webkit_xls/static/description/icon.svg
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,8 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from . import test_general_leger_xls |
|||
from . import test_partner_ledger_xls |
|||
from . import test_trial_balance_xls |
|||
from . import test_partner_balance_xls |
|||
from . import test_open_invoices_xls |
|||
from . import test_aged_partner_balance_xls |
|||
from . import test_aged_open_invoices_xls |
@ -0,0 +1,33 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009-2017 Noviat. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from datetime import datetime |
|||
from .test_common_xls import TestCommonXls |
|||
|
|||
|
|||
class TestAgedOpenInvoicesXls(TestCommonXls): |
|||
|
|||
def _getReportModel(self): |
|||
return 'aged.open.invoices.webkit' |
|||
|
|||
def _getXlsReportName(self): |
|||
return 'account.aged_open_invoices_xls' |
|||
|
|||
def _getXlsReportActionName(self): |
|||
module = 'account_financial_report_webkit' |
|||
action = 'account_report_open_invoices_webkit' |
|||
return '%s.%s' % (module, action) |
|||
|
|||
def _getBaseFilters(self): |
|||
return { |
|||
'date_from': '%s-01-01' % (datetime.now().year), |
|||
'date_to': '%s-12-31' % (datetime.now().year), |
|||
'until_date': '%s-12-31' % (datetime.now().year), |
|||
} |
|||
|
|||
def test_common(self): |
|||
common_tests = [ |
|||
x for x in dir(self) |
|||
if callable(getattr(self, x)) and x.startswith('common_test_')] |
|||
for test in common_tests: |
|||
getattr(self, test)() |
@ -0,0 +1,31 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009-2017 Noviat. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from .test_common_xls import TestCommonXls |
|||
|
|||
|
|||
class TestAgedPartnerBalanceXls(TestCommonXls): |
|||
|
|||
def _getReportModel(self): |
|||
return 'account.aged.trial.balance.webkit' |
|||
|
|||
def _getXlsReportName(self): |
|||
return 'account.account_report_aged_partner_balance_xls' |
|||
|
|||
def _getXlsReportActionName(self): |
|||
module = 'account_financial_report_webkit' |
|||
action = 'account_report_aged_trial_blanance_webkit' |
|||
return '%s.%s' % (module, action) |
|||
|
|||
def _getBaseFilters(self): |
|||
fy_id = self.model._get_current_fiscalyear() |
|||
vals = self.model.onchange_fiscalyear(fiscalyear=fy_id)['value'] |
|||
vals.update({'fiscalyear_id': fy_id}) |
|||
return vals |
|||
|
|||
def test_common(self): |
|||
common_tests = [ |
|||
x for x in dir(self) |
|||
if callable(getattr(self, x)) and x.startswith('common_test_')] |
|||
for test in common_tests: |
|||
getattr(self, test)() |
@ -0,0 +1,60 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009-2017 Noviat. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from openerp.tests.common import TransactionCase |
|||
|
|||
|
|||
class TestCommonXls(TransactionCase): |
|||
""" Common tests for all XLS Exports """ |
|||
|
|||
def setUp(self): |
|||
super(TestCommonXls, self).setUp() |
|||
self.model = self.env[self._getReportModel()] |
|||
self.xls_report_name = self._getXlsReportName() |
|||
ctx = {'xls_export': 1} |
|||
self.xls_action_name = self._getXlsReportActionName() |
|||
self.xls_action = self.env.ref(self.xls_action_name).with_context(ctx) |
|||
wiz_vals = {'chart_account_id': self.env.ref('account.chart0').id} |
|||
wiz_vals.update(self._getBaseFilters()) |
|||
self.report = self.model.with_context(ctx).create(wiz_vals) |
|||
|
|||
def common_test_01_action_xls(self): |
|||
""" Check if report XLS action is correct """ |
|||
report_action = self.report.xls_export() |
|||
self.assertDictContainsSubset( |
|||
{'type': 'ir.actions.report.xml', |
|||
'report_name': self.xls_report_name}, |
|||
report_action) |
|||
self.render_dict = report_action['datas'] |
|||
|
|||
def common_test_02_render_xls(self): |
|||
report_xls = self.xls_action.render_report( |
|||
self.report.ids, |
|||
self.xls_report_name, |
|||
self.render_dict) |
|||
self.assertGreaterEqual(len(report_xls[0]), 1) |
|||
self.assertEqual(report_xls[1], 'xls') |
|||
|
|||
def _getReportModel(self): |
|||
""" |
|||
:return: the report model name |
|||
""" |
|||
raise NotImplementedError() |
|||
|
|||
def _getXlsReportName(self): |
|||
""" |
|||
:return: the xls report name |
|||
""" |
|||
raise NotImplementedError() |
|||
|
|||
def _getXlsReportActionName(self): |
|||
""" |
|||
:return: the xls report action name |
|||
""" |
|||
raise NotImplementedError() |
|||
|
|||
def _getBaseFilters(self): |
|||
""" |
|||
:return: the minimum required filters to generate report |
|||
""" |
|||
raise NotImplementedError() |
@ -0,0 +1,28 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009-2017 Noviat. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from .test_common_xls import TestCommonXls |
|||
|
|||
|
|||
class TestGeneralLedgerXls(TestCommonXls): |
|||
|
|||
def _getReportModel(self): |
|||
return 'general.ledger.webkit' |
|||
|
|||
def _getXlsReportName(self): |
|||
return 'account.account_report_general_ledger_xls' |
|||
|
|||
def _getXlsReportActionName(self): |
|||
module = 'account_financial_report_webkit' |
|||
action = 'account_report_general_ledger_webkit' |
|||
return '%s.%s' % (module, action) |
|||
|
|||
def _getBaseFilters(self): |
|||
return {} |
|||
|
|||
def test_common(self): |
|||
common_tests = [ |
|||
x for x in dir(self) |
|||
if callable(getattr(self, x)) and x.startswith('common_test_')] |
|||
for test in common_tests: |
|||
getattr(self, test)() |
@ -0,0 +1,29 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009-2017 Noviat. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from datetime import datetime |
|||
from .test_common_xls import TestCommonXls |
|||
|
|||
|
|||
class TestOpenInvoicesXls(TestCommonXls): |
|||
|
|||
def _getReportModel(self): |
|||
return 'open.invoices.webkit' |
|||
|
|||
def _getXlsReportName(self): |
|||
return 'account.account_report_open_invoices_xls' |
|||
|
|||
def _getXlsReportActionName(self): |
|||
module = 'account_financial_report_webkit' |
|||
action = 'account_report_open_invoices_webkit' |
|||
return '%s.%s' % (module, action) |
|||
|
|||
def _getBaseFilters(self): |
|||
return {'until_date': '%s-12-31' % (datetime.now().year)} |
|||
|
|||
def test_common(self): |
|||
common_tests = [ |
|||
x for x in dir(self) |
|||
if callable(getattr(self, x)) and x.startswith('common_test_')] |
|||
for test in common_tests: |
|||
getattr(self, test)() |
@ -0,0 +1,28 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009-2017 Noviat. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from .test_common_xls import TestCommonXls |
|||
|
|||
|
|||
class TestPartnerBalanceXls(TestCommonXls): |
|||
|
|||
def _getReportModel(self): |
|||
return 'partner.balance.webkit' |
|||
|
|||
def _getXlsReportName(self): |
|||
return 'account.account_report_partner_balance_xls' |
|||
|
|||
def _getXlsReportActionName(self): |
|||
module = 'account_financial_report_webkit' |
|||
action = 'account_report_partner_balance_webkit' |
|||
return '%s.%s' % (module, action) |
|||
|
|||
def _getBaseFilters(self): |
|||
return {} |
|||
|
|||
def test_common(self): |
|||
common_tests = [ |
|||
x for x in dir(self) |
|||
if callable(getattr(self, x)) and x.startswith('common_test_')] |
|||
for test in common_tests: |
|||
getattr(self, test)() |
@ -0,0 +1,28 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009-2017 Noviat. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from .test_common_xls import TestCommonXls |
|||
|
|||
|
|||
class TestPartnerLedgerXls(TestCommonXls): |
|||
|
|||
def _getReportModel(self): |
|||
return 'partners.ledger.webkit' |
|||
|
|||
def _getXlsReportName(self): |
|||
return 'account.account_report_partner_ledger_xls' |
|||
|
|||
def _getXlsReportActionName(self): |
|||
module = 'account_financial_report_webkit' |
|||
action = 'account_report_partners_ledger_webkit' |
|||
return '%s.%s' % (module, action) |
|||
|
|||
def _getBaseFilters(self): |
|||
return {} |
|||
|
|||
def test_common(self): |
|||
common_tests = [ |
|||
x for x in dir(self) |
|||
if callable(getattr(self, x)) and x.startswith('common_test_')] |
|||
for test in common_tests: |
|||
getattr(self, test)() |
@ -0,0 +1,28 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009-2017 Noviat. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from .test_common_xls import TestCommonXls |
|||
|
|||
|
|||
class TestTrialBalanceXls(TestCommonXls): |
|||
|
|||
def _getReportModel(self): |
|||
return 'trial.balance.webkit' |
|||
|
|||
def _getXlsReportName(self): |
|||
return 'account.account_report_trial_balance_xls' |
|||
|
|||
def _getXlsReportActionName(self): |
|||
module = 'account_financial_report_webkit' |
|||
action = 'account_report_trial_balance_webkit' |
|||
return '%s.%s' % (module, action) |
|||
|
|||
def _getBaseFilters(self): |
|||
return {} |
|||
|
|||
def test_common(self): |
|||
common_tests = [ |
|||
x for x in dir(self) |
|||
if callable(getattr(self, x)) and x.startswith('common_test_')] |
|||
for test in common_tests: |
|||
getattr(self, test)() |
@ -1,27 +1,8 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# OpenERP, Open Source Management Solution |
|||
# |
|||
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved. |
|||
# |
|||
# This program is free software: you can redistribute it and/or modify |
|||
# it under the terms of the GNU Affero General Public License as |
|||
# published by the Free Software Foundation, either version 3 of the |
|||
# License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU Affero General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU Affero General Public License |
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
|
|||
# -*- coding: utf-8 -*- |
|||
from . import general_ledger_wizard |
|||
from . import trial_balance_wizard |
|||
from . import partners_balance_wizard |
|||
from . import partners_ledger_wizard |
|||
from . import open_invoices_wizard |
|||
from . import aged_partner_balance_wizard |
|||
from . import aged_open_invoices_wizard |
@ -0,0 +1,27 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009-2016 Noviat. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from openerp import models |
|||
|
|||
|
|||
class AgedOpenInvoice(models.TransientModel): |
|||
_inherit = 'aged.open.invoices.webkit' |
|||
|
|||
# pylint: disable=old-api7-method-defined |
|||
def xls_export(self, cr, uid, ids, context=None): |
|||
return self.check_report(cr, uid, ids, context=context) |
|||
|
|||
# pylint: disable=old-api7-method-defined |
|||
def _print_report(self, cr, uid, ids, data, context=None): |
|||
context = context or {} |
|||
if context.get('xls_export'): |
|||
# we update form with display account value |
|||
data = self.pre_print_report(cr, uid, ids, data, context=context) |
|||
return { |
|||
'type': 'ir.actions.report.xml', |
|||
'report_name': |
|||
'account.aged_open_invoices_xls', |
|||
'datas': data} |
|||
else: |
|||
return super(AgedOpenInvoice, self)._print_report( |
|||
cr, uid, ids, data, context=context) |
@ -0,0 +1,17 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<openerp> |
|||
<data> |
|||
|
|||
<record id="aged_open_invoice_webkit" model="ir.ui.view"> |
|||
<field name="model">aged.open.invoices.webkit</field> |
|||
<field name="type">form</field> |
|||
<field name="inherit_id" ref="account_financial_report_webkit.aged_open_invoice_webkit"/> |
|||
<field name="arch" type="xml"> |
|||
<button string="Print" position="after"> |
|||
<button icon="gtk-execute" name="xls_export" string="Export" type="object" context="{'xls_export':1}" colspan="2"/> |
|||
</button> |
|||
</field> |
|||
</record> |
|||
|
|||
</data> |
|||
</openerp> |
@ -0,0 +1,27 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009-2016 Noviat. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from openerp import models |
|||
|
|||
|
|||
class AccountAgedTrialBalance(models.TransientModel): |
|||
_inherit = 'account.aged.trial.balance.webkit' |
|||
|
|||
# pylint: disable=old-api7-method-defined |
|||
def xls_export(self, cr, uid, ids, context=None): |
|||
return self.check_report(cr, uid, ids, context=context) |
|||
|
|||
# pylint: disable=old-api7-method-defined |
|||
def _print_report(self, cr, uid, ids, data, context=None): |
|||
context = context or {} |
|||
if context.get('xls_export'): |
|||
# we update form with display account value |
|||
data = self.pre_print_report(cr, uid, ids, data, context=context) |
|||
return { |
|||
'type': 'ir.actions.report.xml', |
|||
'report_name': |
|||
'account.account_report_aged_partner_balance_xls', |
|||
'datas': data} |
|||
else: |
|||
return super(AccountAgedTrialBalance, self)._print_report( |
|||
cr, uid, ids, data, context=context) |
@ -0,0 +1,18 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<openerp> |
|||
<data> |
|||
|
|||
<record id="account_aged_trial_balance_webkit" model="ir.ui.view"> |
|||
<field name="name">account.aged.trial.balance.webkit.xls</field> |
|||
<field name="model">account.aged.trial.balance.webkit</field> |
|||
<field name="type">form</field> |
|||
<field name="inherit_id" ref="account_financial_report_webkit.account_aged_trial_balance_webkit"/> |
|||
<field name="arch" type="xml"> |
|||
<button string="Print" position="after"> |
|||
<button icon="gtk-execute" name="xls_export" string="Export" type="object" context="{'xls_export':1}" colspan="2"/> |
|||
</button> |
|||
</field> |
|||
</record> |
|||
|
|||
</data> |
|||
</openerp> |
@ -1,44 +1,27 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# OpenERP, Open Source Management Solution |
|||
# |
|||
# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved. |
|||
# |
|||
# This program is free software: you can redistribute it and/or modify |
|||
# it under the terms of the GNU Affero General Public License as |
|||
# published by the Free Software Foundation, either version 3 of the |
|||
# License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU Affero General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU Affero General Public License |
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009-2016 Noviat. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
from openerp import models |
|||
|
|||
from openerp.osv import orm |
|||
# import logging |
|||
# _logger = logging.getLogger(__name__) |
|||
|
|||
|
|||
class partner_ledger_webkit_wizard(orm.TransientModel): |
|||
class AccountReportPartnersLedgerWizard(models.TransientModel): |
|||
_inherit = 'partners.ledger.webkit' |
|||
|
|||
# pylint: disable=old-api7-method-defined |
|||
def xls_export(self, cr, uid, ids, context=None): |
|||
return self.check_report(cr, uid, ids, context=context) |
|||
|
|||
# pylint: disable=old-api7-method-defined |
|||
def _print_report(self, cr, uid, ids, data, context=None): |
|||
context = context or {} |
|||
if context.get('xls_export'): |
|||
# we update form with display account value |
|||
data = self.pre_print_report(cr, uid, ids, data, context=context) |
|||
return {'type': 'ir.actions.report.xml', |
|||
'report_name': 'account.account_report_partner_ledger_xls', |
|||
'datas': data} |
|||
return { |
|||
'type': 'ir.actions.report.xml', |
|||
'report_name': 'account.account_report_partner_ledger_xls', |
|||
'datas': data} |
|||
else: |
|||
return super(partner_ledger_webkit_wizard, self)._print_report( |
|||
return super( |
|||
AccountReportPartnersLedgerWizard, self)._print_report( |
|||
cr, uid, ids, data, context=context) |
@ -1,23 +1,2 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# OpenERP, Open Source Management Solution |
|||
# |
|||
# Copyright (c) 2014 Noviat nv/sa (www.noviat.com). All rights reserved. |
|||
# |
|||
# This program is free software: you can redistribute it and/or modify |
|||
# it under the terms of the GNU Affero General Public License as |
|||
# published by the Free Software Foundation, either version 3 of the |
|||
# License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU Affero General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU Affero General Public License |
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
|
|||
# -*- coding: utf-8 -*- |
|||
from . import print_journal_wizard |
Write
Preview
Loading…
Cancel
Save
Reference in new issue