Skip to content

Commit

Permalink
Merge pull request #104 from pedrobaeza/8.0-account_balance_reporting…
Browse files Browse the repository at this point in the history
…_xls

[ADD] account_balance_reporting_xls: Exportación a XLS de los informes financieros
  • Loading branch information
pedrobaeza committed Jan 19, 2015
2 parents 21f255c + 33df0e0 commit 06afd85
Show file tree
Hide file tree
Showing 16 changed files with 1,011 additions and 0 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ install:
- pip install unidecode
- git clone https://github.com/OCA/partner-contact ${HOME}/partner-contact -b ${VERSION}
- git clone https://github.com/OCA/account-financial-tools ${HOME}/account-financial-tools -b ${VERSION}
- git clone https://github.com/OCA/reporting-engines ${HOME}/reporting-engines -b ${VERSION}
- git clone https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools
- export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}
- travis_install_nightly
Expand Down
14 changes: 14 additions & 0 deletions account_balance_reporting_xls/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Excel export for account balance reporting engine
=================================================

This module allows to export financial reports to XLS files from print dialog.

**WARNING:** This module requires module *report_xls*, available on:

https://github.com/OCA/reporting-engine/

Contributors
------------
* Alejandro Santana <alejandrosantana@anubia.es>
* Juan Formoso <jfv@anubia.es>
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com
9 changes: 9 additions & 0 deletions account_balance_reporting_xls/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# -*- coding: utf-8 -*-
################################################################
# License, author and contributors information in: #
# __openerp__.py file at the root folder of this module. #
################################################################

from . import models
from . import report
from . import wizard
45 changes: 45 additions & 0 deletions account_balance_reporting_xls/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
#
# Copyright (c)
# 2014 - Anubía, soluciones en la nube,SL (http://www.anubia.es)
# Juan Formoso <jfv@anubia.es>
# Alejandro Santana <alejandrosantana@anubia.es>
#
# 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
#
##############################################################################

{
"name": "Account balance reporting to XLS",
"version": "1.0",
"author": "Spanish Localization Team",
'website': 'http://odoo-spain.org',
"category": "Accounting / Reports",
'depends': [
'account_balance_reporting',
'report_xls',
],
'contributors': [
'Alejandro Santana <alejandrosantana@anubia.es>',
'Juan Formoso <jfv@anubia.es>',
'Pedro M. Baeza <pedro.baeza@serviciosbaeza.com',
],
'data': [
'wizard/account_balance_reporting_wizard.xml',
],
'installable': True,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_balance_reporting_xls
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-01-17 15:55+0000\n"
"PO-Revision-Date: 2015-01-17 15:55+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: account_balance_reporting_xls
#: view:account.balance.reporting.print.wizard:account_balance_reporting_xls.wizard_account_balance_reporting_xls_print
msgid "Export"
msgstr ""

#. module: account_balance_reporting_xls
#: code:addons/account_balance_reporting_xls/report/reporting_xls.py:65
#, python-format
msgid "Concept"
msgstr ""

#. module: account_balance_reporting_xls
#: code:addons/account_balance_reporting_xls/report/reporting_xls.py:70
#, python-format
msgid "Code"
msgstr ""

#. module: account_balance_reporting_xls
#: code:addons/account_balance_reporting_xls/report/reporting_xls.py:75
#, python-format
msgid "Previous value"
msgstr ""

#. module: account_balance_reporting_xls
#: code:addons/account_balance_reporting_xls/report/reporting_xls.py:82
#, python-format
msgid "Current value"
msgstr ""

#. module: account_balance_reporting_xls
#: code:addons/account_balance_reporting_xls/report/reporting_xls.py:89
#, python-format
msgid "Balance"
msgstr ""

#. module: account_balance_reporting_xls
#: code:addons/account_balance_reporting_xls/report/reporting_xls.py:96
#, python-format
msgid "Notes"
msgstr ""

58 changes: 58 additions & 0 deletions account_balance_reporting_xls/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_balance_reporting_xls
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-01-17 15:55+0000\n"
"PO-Revision-Date: 2015-01-17 15:55+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: account_balance_reporting_xls
#: view:account.balance.reporting.print.wizard:account_balance_reporting_xls.wizard_account_balance_reporting_xls_print
msgid "Export"
msgstr "Exportar"

#. module: account_balance_reporting_xls
#: code:addons/account_balance_reporting_xls/report/reporting_xls.py:65
#, python-format
msgid "Concept"
msgstr "Concepto"

#. module: account_balance_reporting_xls
#: code:addons/account_balance_reporting_xls/report/reporting_xls.py:70
#, python-format
msgid "Code"
msgstr "Código"

#. module: account_balance_reporting_xls
#: code:addons/account_balance_reporting_xls/report/reporting_xls.py:75
#, python-format
msgid "Previous value"
msgstr "Valor anterior"

#. module: account_balance_reporting_xls
#: code:addons/account_balance_reporting_xls/report/reporting_xls.py:82
#, python-format
msgid "Current value"
msgstr "Valor actual"

#. module: account_balance_reporting_xls
#: code:addons/account_balance_reporting_xls/report/reporting_xls.py:89
#, python-format
msgid "Balance"
msgstr "Saldo"

#. module: account_balance_reporting_xls
#: code:addons/account_balance_reporting_xls/report/reporting_xls.py:96
#, python-format
msgid "Notes"
msgstr "Notas"

7 changes: 7 additions & 0 deletions account_balance_reporting_xls/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
################################################################
# License, author and contributors information in: #
# __openerp__.py file at the root folder of this module. #
################################################################

from . import account_balance_reporting
31 changes: 31 additions & 0 deletions account_balance_reporting_xls/models/account_balance_reporting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# License, author and contributors information in:
# __openerp__.py file at the root folder of this module.

from openerp.osv import orm


class AccountBalanceReporting(orm.Model):
_inherit = "account.balance.reporting"

def _report_xls_document_extra(self, cr, uid, context):
"""Inherit this for adding/changing document references.
"""
return ""

def _report_xls_fields(self, cr, uid, context=None):
"""Inherit this for adding/changing fields to export to XLS file.
"""
return [
'name', # account.balance.reporting.line, name
'code',
'notes',
'previous_value',
'current_value',
'balance',
]

def _report_xls_template(self, cr, uid, context=None):
"""Inherit this for adding/changing template entries.
"""
return {}
8 changes: 8 additions & 0 deletions account_balance_reporting_xls/report/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
################################################################
# License, author and contributors information in: #
# __openerp__.py file at the root folder of this module. #
################################################################

from . import reporting_xls
from . import reporting
79 changes: 79 additions & 0 deletions account_balance_reporting_xls/report/reporting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# -*- coding: utf-8 -*-
# License, author and contributors information in:
# __openerp__.py file at the root folder of this module.

import time
from openerp.report import report_sxw
from openerp.tools.translate import translate

_ir_translation_name = 'account.balance.reporting.print'


class AccountBalanceReportingPrint(report_sxw.rml_parse):

def set_context(self, objects, data, ids, report_type=None):
super(AccountBalanceReportingPrint, self).set_context(
objects, data, ids)
self.report_type = report_type
self.report_id = data['report_id']
self.report_name = data['report_name']
self.report_design = data['report_design']
self.localcontext.update({
'additional_data': self._get_additional_data(),
})

def __init__(self, cr, uid, name, context):
super(AccountBalanceReportingPrint, self).__init__(
cr, uid, name, context=context)
self.localcontext.update({
'time': time,
'lines': self._lines,
'_': self._,
})
self.context = context

def _(self, src):
lang = self.context.get('lang', 'en_US')
return translate(self.cr, _ir_translation_name, 'report', lang,
src) or src

def _get_additional_data(self):
abr_obj = self.pool['account.balance.reporting']
abr = abr_obj.browse(
self.cr, self.uid, self.report_id, self.context)
fields = {
'calc_date': abr and abr.calc_date or False,
'tname': abr and abr.template_id and abr.template_id.name or False,
}
return fields

def _lines(self, obj):
user = self.pool['res.users'].browse(self.cr, self.uid, self.uid)
ctx_lang = {'lang': user.lang}
zero_report = self.pool['ir.model.data'].get_object(
self.cr, self.uid, 'account_balance_reporting',
'report_account_balance_reporting_default_non_zero',
context=ctx_lang)
non_zero = self.report_design == zero_report.name
# No SQL is used, as performance should not be a problem using
# already calculated values.
lines = []
for line in obj.line_ids:
line_balance = (line.current_value - line.previous_value)
if non_zero and abs(line_balance) < 0.005:
continue
notes = line.notes and line.notes.encode('utf-8') or ''
line_fields = {
'code': line.code,
'name': line.name,
'previous_value': line.previous_value,
'current_value': line.current_value,
'balance': line_balance,
'notes': notes,
}
lines.append(line_fields)
return lines

report_sxw.report_sxw(
'report.account.balance.reporting.print', 'account.balance.reporting',
parser=AccountBalanceReportingPrint, header=False)

0 comments on commit 06afd85

Please sign in to comment.