luc-demeyer
8 years ago
committed by
Holger Brunn
No known key found for this signature in database
GPG Key ID: 1C9760FECA3AE18
32 changed files with 752 additions and 99 deletions
-
1account_financial_report_webkit/README.rst
-
2account_financial_report_webkit/__openerp__.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
-
26account_financial_report_webkit/wizard/__init__.py
-
121account_financial_report_webkit/wizard/account_common_report_fix.py
-
37account_financial_report_webkit/wizard/aged_partner_balance_wizard.py
-
64account_financial_report_webkit_xls/README.rst
-
24account_financial_report_webkit_xls/__openerp__.py
-
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
-
7account_financial_report_webkit_xls/tests/__init__.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
-
24account_journal_report_xls/wizard/__init__.py
-
65account_journal_report_xls/wizard/account_common_report_fix.py
@ -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,121 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009-2017 Noviat. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
""" |
|||
Bypass of bug in Odoo: |
|||
The financial reports do not work on first and last day of the Fiscal Year. |
|||
This fix can be removed after merge of |
|||
PR https://github.com/odoo/odoo/pull/14891. |
|||
""" |
|||
import logging |
|||
import time |
|||
from openerp import api, fields, models |
|||
_logger = logging.getLogger(__name__) |
|||
|
|||
|
|||
class AccountCommonReportFix(object): |
|||
|
|||
@api.model |
|||
def _default_fiscalyear_id(self): |
|||
_logger.debug( |
|||
'%s, fix cf. PR https://github.com/odoo/odoo/pull/14891', |
|||
self._name) |
|||
fy_id = super(AccountCommonReportFix, self)._get_fiscalyear() |
|||
if fy_id: |
|||
return self.env['account.fiscalyear'].browse(fy_id) |
|||
|
|||
now = time.strftime('%Y-%m-%d') |
|||
ids = self._context.get('active_ids', []) |
|||
if ids and self._context.get('active_model') == 'account.account': |
|||
company = self.env['account.account'].browse(ids[0]) |
|||
else: # use current company id |
|||
company = self.env.user.company_id |
|||
domain = [('company_id', '=', company.id), |
|||
('date_start', '<=', now), ('date_stop', '>=', now)] |
|||
return self.env['account.fiscalyear'].search(domain, limit=1) |
|||
|
|||
def onchange_chart_id(self, cr, uid, ids, |
|||
chart_account_id=False, context=None): |
|||
_logger.debug( |
|||
'%s, fix cf. PR https://github.com/odoo/odoo/pull/14891', |
|||
self._name) |
|||
res = super(AccountCommonReportFix, self).onchange_chart_id( |
|||
cr, uid, ids, chart_account_id=chart_account_id, context=context) |
|||
if not res.get('fiscalyear_id'): |
|||
if chart_account_id: |
|||
company_id = self.pool['account.account'].browse( |
|||
cr, uid, chart_account_id, context=context).company_id.id |
|||
now = time.strftime('%Y-%m-%d') |
|||
domain = [('company_id', '=', company_id), |
|||
('date_start', '<=', now), ('date_stop', '>=', now)] |
|||
fiscalyears = self.pool['account.fiscalyear'].search( |
|||
cr, uid, domain, limit=1) |
|||
res['value'] = { |
|||
'company_id': company_id, |
|||
'fiscalyear_id': fiscalyears and fiscalyears[0] or False, |
|||
} |
|||
return res |
|||
|
|||
|
|||
class AccountReportGeneralLedgerWizard(AccountCommonReportFix, |
|||
models.TransientModel): |
|||
_inherit = 'general.ledger.webkit' |
|||
|
|||
fiscalyear_id = fields.Many2one( |
|||
default=lambda self: self._default_fiscalyear_id()) |
|||
|
|||
|
|||
class AgedOpenInvoice(AccountCommonReportFix, |
|||
models.TransientModel): |
|||
_inherit = 'aged.open.invoices.webkit' |
|||
|
|||
fiscalyear_id = fields.Many2one( |
|||
default=lambda self: self._default_fiscalyear_id()) |
|||
|
|||
|
|||
class AccountAgedTrialBalance(AccountCommonReportFix, |
|||
models.TransientModel): |
|||
_inherit = 'account.aged.trial.balance.webkit' |
|||
|
|||
# no fiscalyear_id in this one since the module has |
|||
# its own method for this. |
|||
|
|||
|
|||
class AccountReportOpenInvoicesWizard(AccountCommonReportFix, |
|||
models.TransientModel): |
|||
_inherit = 'open.invoices.webkit' |
|||
|
|||
fiscalyear_id = fields.Many2one( |
|||
default=lambda self: self._default_fiscalyear_id()) |
|||
|
|||
|
|||
class AccountPartnerBalanceWizard(AccountCommonReportFix, |
|||
models.TransientModel): |
|||
_inherit = 'partner.balance.webkit' |
|||
|
|||
fiscalyear_id = fields.Many2one( |
|||
default=lambda self: self._default_fiscalyear_id()) |
|||
|
|||
|
|||
class AccountReportPartnersLedgerWizard(AccountCommonReportFix, |
|||
models.TransientModel): |
|||
_inherit = 'partners.ledger.webkit' |
|||
|
|||
fiscalyear_id = fields.Many2one( |
|||
default=lambda self: self._default_fiscalyear_id()) |
|||
|
|||
|
|||
class AccountReportPrintJournalWizard(AccountCommonReportFix, |
|||
models.TransientModel): |
|||
_inherit = 'print.journal.webkit' |
|||
|
|||
fiscalyear_id = fields.Many2one( |
|||
default=lambda self: self._default_fiscalyear_id()) |
|||
|
|||
|
|||
class AccountTrialBalanceWizard(AccountCommonReportFix, |
|||
models.TransientModel): |
|||
_inherit = 'trial.balance.webkit' |
|||
|
|||
fiscalyear_id = fields.Many2one( |
|||
default=lambda self: self._default_fiscalyear_id()) |
@ -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,7 @@ |
|||
# -*- 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 |
@ -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,23 +1,3 @@ |
|||
# -*- 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 |
|||
from . import account_common_report_fix |
@ -0,0 +1,65 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009-2017 Noviat. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
""" |
|||
Bypass of bug in Odoo: |
|||
The financial reports do not work on first and last day of the Fiscal Year. |
|||
This fix can be removed after merge of |
|||
PR https://github.com/odoo/odoo/pull/14891. |
|||
""" |
|||
import logging |
|||
import time |
|||
from openerp import api, fields, models |
|||
_logger = logging.getLogger(__name__) |
|||
|
|||
|
|||
class AccountCommonReportFix(object): |
|||
|
|||
@api.model |
|||
def _default_fiscalyear_id(self): |
|||
_logger.debug( |
|||
'%s, fix cf. PR https://github.com/odoo/odoo/pull/14891', |
|||
self._name) |
|||
fy_id = super(AccountCommonReportFix, self)._get_fiscalyear() |
|||
if fy_id: |
|||
return self.env['account.fiscalyear'].browse(fy_id) |
|||
|
|||
now = time.strftime('%Y-%m-%d') |
|||
ids = self._context.get('active_ids', []) |
|||
if ids and self._context.get('active_model') == 'account.account': |
|||
company = self.env['account.account'].browse(ids[0]) |
|||
else: # use current company id |
|||
company = self.env.user.company_id |
|||
domain = [('company_id', '=', company.id), |
|||
('date_start', '<=', now), ('date_stop', '>=', now)] |
|||
return self.env['account.fiscalyear'].search(domain, limit=1) |
|||
|
|||
def onchange_chart_id(self, cr, uid, ids, |
|||
chart_account_id=False, context=None): |
|||
_logger.debug( |
|||
'%s, fix cf. PR https://github.com/odoo/odoo/pull/14891', |
|||
self._name) |
|||
res = super(AccountCommonReportFix, self).onchange_chart_id( |
|||
cr, uid, ids, chart_account_id=chart_account_id, context=context) |
|||
if not res.get('fiscalyear_id'): |
|||
if chart_account_id: |
|||
company_id = self.pool['account.account'].browse( |
|||
cr, uid, chart_account_id, context=context).company_id.id |
|||
now = time.strftime('%Y-%m-%d') |
|||
domain = [('company_id', '=', company_id), |
|||
('date_start', '<=', now), ('date_stop', '>=', now)] |
|||
fiscalyears = self.pool['account.fiscalyear'].search( |
|||
cr, uid, domain, limit=1) |
|||
res['value'] = { |
|||
'company_id': company_id, |
|||
'fiscalyear_id': fiscalyears and fiscalyears[0] or False, |
|||
} |
|||
return res |
|||
|
|||
|
|||
class AccountPrintJournalXls(AccountCommonReportFix, |
|||
models.TransientModel): |
|||
_inherit = 'account.print.journal.xls' |
|||
|
|||
fiscalyear_id = fields.Many2one( |
|||
default=lambda self: self._default_fiscalyear_id()) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue