Holger Brunn
8 years ago
committed by
Nikos Tsirintanis
9 changed files with 74 additions and 132 deletions
-
2account_financial_report_horizontal/README.rst
-
31account_financial_report_horizontal/__manifest__.py
-
20account_financial_report_horizontal/models/__init__.py
-
43account_financial_report_horizontal/models/account_financial_report.py
-
2account_financial_report_horizontal/report/__init__.py
-
64account_financial_report_horizontal/report/report_financial.py
-
20account_financial_report_horizontal/report/report_financial.xml
-
4account_financial_report_horizontal/tests/__init__.py
-
20account_financial_report_horizontal/tests/test_account_financial_report_horizontal.py
@ -1,21 +1,3 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# OpenERP, Open Source Management Solution |
|||
# This module copyright (C) 2015 Therp BV (<http://therp.nl>). |
|||
# |
|||
# 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/>. |
|||
# |
|||
############################################################################## |
|||
# © 2015 Therp BV <http://therp.nl> |
|||
from . import account_financial_report |
@ -1 +1,3 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2015 Therp BV <http://therp.nl> |
|||
from . import report_financial |
@ -1,54 +1,28 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# OpenERP, Open Source Management Solution |
|||
# This module copyright (C) 2015 Therp BV (<http://therp.nl>). |
|||
# |
|||
# 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/>. |
|||
# |
|||
############################################################################## |
|||
import copy |
|||
from openerp import models |
|||
from openerp.addons.account.report.account_financial_report import\ |
|||
report_account_common |
|||
# © 2016 Therp BV <http://therp.nl> |
|||
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) |
@ -0,0 +1,4 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Therp BV <http://therp.nl> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
from . import test_account_financial_report_horizontal |
@ -0,0 +1,20 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Therp BV <http://therp.nl> |
|||
# 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"]')) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue