diff --git a/account_financial_report_horizontal/README.rst b/account_financial_report_horizontal/README.rst index 4ca2e6fb..da34445f 100644 --- a/account_financial_report_horizontal/README.rst +++ b/account_financial_report_horizontal/README.rst @@ -11,8 +11,6 @@ Usage After the module is installed, the balance sheet and profit and loss reports will be in landscape mode with assets left and liabilities right. -* https://www.odoo.com/forum/help-1 - Credits ======= diff --git a/account_financial_report_horizontal/__openerp__.py b/account_financial_report_horizontal/__openerp__.py index 1bff8058..ee65eeb7 100644 --- a/account_financial_report_horizontal/__openerp__.py +++ b/account_financial_report_horizontal/__openerp__.py @@ -1,28 +1,11 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# This module copyright (C) 2012 Therp BV (), -# Copyright (C) 2013 Agile Business Group sagl -# () () -# -# 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 . -# -############################################################################## +# © 2012-2016 Therp BV +# © 2013 Agile Business Group sagl +# +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { "name": "Accounting Financial Reports Horizontal", - "version": "8.0.0.3.0", + "version": "9.0.0.0.0", "author": "Therp BV,Agile Business Group,Odoo Community Association (OCA)", "category": 'Accounting & Finance', 'website': 'https://github.com/OCA/account-financial-reporting', @@ -33,8 +16,4 @@ "data/ir_actions_report_xml.xml", "report/report_financial.xml", ], - 'demo': [], - 'test': [], - 'active': False, - 'installable': False, } diff --git a/account_financial_report_horizontal/models/__init__.py b/account_financial_report_horizontal/models/__init__.py index d9e791d3..3e6d5600 100644 --- a/account_financial_report_horizontal/models/__init__.py +++ b/account_financial_report_horizontal/models/__init__.py @@ -1,21 +1,3 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# This module copyright (C) 2015 Therp BV (). -# -# 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 . -# -############################################################################## +# © 2015 Therp BV from . import account_financial_report diff --git a/account_financial_report_horizontal/models/account_financial_report.py b/account_financial_report_horizontal/models/account_financial_report.py index b30f91ca..a645324b 100644 --- a/account_financial_report_horizontal/models/account_financial_report.py +++ b/account_financial_report_horizontal/models/account_financial_report.py @@ -1,23 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# This module copyright (C) 2015 Therp BV (). -# -# 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 . -# -############################################################################## +# © 2015 Therp BV from openerp import models, api @@ -29,11 +11,11 @@ class AccountFinancialReport(models.Model): self.ensure_one() if self.type == 'accounts': for account in self.account_ids: - if account.user_type.report_type not in report_types: + if account.user_type_id.type not in report_types: return False elif self.type == 'account_type': for account_type in self.account_type_ids: - if account_type.report_type not in report_types: + if account_type.type not in report_types: return False elif self.type == 'account_report': # this will have mixed types usually, we rely upon this being @@ -49,23 +31,24 @@ class AccountFinancialReport(models.Model): if self.env.context.get('account_financial_report_horizontal_side'): side = self.env.context['account_financial_report_horizontal_side'] report_types = { - 'left': ['income', 'asset', 'none'], - 'right': ['expense', 'liability', 'none'] + 'left': ['receivable', 'liquidity', 'other'], + 'right': ['payable', 'other'] }[side] - last_good_report = None - last_bad_report = None - for report in self.browse(reports): + last_good_report = self.browse([]) + last_bad_report = self.browse([]) + result = self.browse([]) + for report in reports: if not report.parent_id: - yield report.id + result += report # don't check children if we already checked the parent elif report.parent_id == last_bad_report: continue elif report.parent_id == last_good_report\ or report._has_exclusively_report_types(report_types): last_good_report = report - yield report.id + result += report else: last_bad_report = report + return result else: - for report_id in reports: - yield report_id + return reports diff --git a/account_financial_report_horizontal/report/__init__.py b/account_financial_report_horizontal/report/__init__.py index f9bf7bbd..51dba30c 100644 --- a/account_financial_report_horizontal/report/__init__.py +++ b/account_financial_report_horizontal/report/__init__.py @@ -1 +1,3 @@ +# -*- coding: utf-8 -*- +# © 2015 Therp BV from . import report_financial diff --git a/account_financial_report_horizontal/report/report_financial.py b/account_financial_report_horizontal/report/report_financial.py index 9af2c836..a4cc7600 100644 --- a/account_financial_report_horizontal/report/report_financial.py +++ b/account_financial_report_horizontal/report/report_financial.py @@ -1,54 +1,28 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# This module copyright (C) 2015 Therp BV (). -# -# 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 . -# -############################################################################## -import copy -from openerp import models -from openerp.addons.account.report.account_financial_report import\ - report_account_common +# © 2016 Therp BV +from openerp import api, models -class report_account_common_horizontal(report_account_common): - def __init__(self, cr, uid, name, context=None): - super(report_account_common_horizontal, self).__init__( - cr, uid, name, context=context) - self.localcontext.update({ - 'get_left_lines': self.get_left_lines, - 'get_right_lines': self.get_right_lines, - }) +class ReportFinancial(models.AbstractModel): + _inherit = 'report.account.report_financial' - def get_lines(self, data, side=None): - data = copy.deepcopy(data) - if data['form']['used_context'] is None: - data['form']['used_context'] = {} - data['form']['used_context'].update( - account_financial_report_horizontal_side=side) - return super(report_account_common_horizontal, self).get_lines( - data) + def get_account_lines(self, data, side=None): + return super( + ReportFinancial, self.with_context( + account_financial_report_horizontal_side=side, + ) + ).get_account_lines(data) def get_left_lines(self, data): - return self.get_lines(data, side='left') + return self.get_account_lines(data, side='left') def get_right_lines(self, data): - return self.get_lines(data, side='right') - + return self.get_account_lines(data, side='right') -class ReportFinancial(models.AbstractModel): - _inherit = 'report.account.report_financial' - _wrapped_report_class = report_account_common_horizontal + @api.multi + def render_html(self, data): + data.setdefault('form', {}).update( + get_left_lines=self.get_left_lines, + get_right_lines=self.get_right_lines, + ) + return super(ReportFinancial, self).render_html(data) diff --git a/account_financial_report_horizontal/report/report_financial.xml b/account_financial_report_horizontal/report/report_financial.xml index 08d1b7a0..9eb42ae7 100644 --- a/account_financial_report_horizontal/report/report_financial.xml +++ b/account_financial_report_horizontal/report/report_financial.xml @@ -10,15 +10,15 @@
-
+
- - + + - + @@ -31,14 +31,14 @@ - - - - + + diff --git a/account_financial_report_horizontal/tests/__init__.py b/account_financial_report_horizontal/tests/__init__.py new file mode 100644 index 00000000..e3440ae3 --- /dev/null +++ b/account_financial_report_horizontal/tests/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# © 2016 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import test_account_financial_report_horizontal diff --git a/account_financial_report_horizontal/tests/test_account_financial_report_horizontal.py b/account_financial_report_horizontal/tests/test_account_financial_report_horizontal.py new file mode 100644 index 00000000..90723712 --- /dev/null +++ b/account_financial_report_horizontal/tests/test_account_financial_report_horizontal.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# © 2016 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from lxml import etree +from openerp.tests.common import TransactionCase + + +class TestAccountFinancialReportHorizontal(TransactionCase): + def test_account_financial_report_horizontal(self): + action = self.env['accounting.report'].with_context( + active_id=self.env.ref('account.menu_account_report_pl').id, + active_model='ir.ui.view', + ).create({}).check_report() + data = action['data'] + html = self.env['report'].with_context(action['context']).get_html( + self.env[data['model']].browse(data['ids']), + action['report_name'], + data=data, + ) + self.assertTrue(etree.fromstring(html).xpath('//div[@class="row"]'))
NameDebitCreditDebitCredit Balance
- + + - + +