← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~luc-demeyer/account-financial-report/7.0-add-account_trial_balance_period_xls into lp:account-financial-report

 

Luc De Meyer (Noviat) has proposed merging lp:~luc-demeyer/account-financial-report/7.0-add-account_trial_balance_period_xls into lp:account-financial-report.

Requested reviews:
  Account Report Core Editors (account-report-core-editor)

For more details, see:
https://code.launchpad.net/~luc-demeyer/account-financial-report/7.0-add-account_trial_balance_period_xls/+merge/224024

New module with trial balance per period in XLS format.
-- 
https://code.launchpad.net/~luc-demeyer/account-financial-report/7.0-add-account_trial_balance_period_xls/+merge/224024
Your team Account Report Core Editors is requested to review the proposed merge of lp:~luc-demeyer/account-financial-report/7.0-add-account_trial_balance_period_xls into lp:account-financial-report.
=== added directory 'account_trial_balance_period_xls'
=== added file 'account_trial_balance_period_xls/__init__.py'
--- account_trial_balance_period_xls/__init__.py	1970-01-01 00:00:00 +0000
+++ account_trial_balance_period_xls/__init__.py	2014-06-21 15:52:31 +0000
@@ -0,0 +1,26 @@
+# -*- 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/>.
+#
+##############################################################################
+
+from . import wizard
+from . import report
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'account_trial_balance_period_xls/__openerp__.py'
--- account_trial_balance_period_xls/__openerp__.py	1970-01-01 00:00:00 +0000
+++ account_trial_balance_period_xls/__openerp__.py	2014-06-21 15:52:31 +0000
@@ -0,0 +1,40 @@
+# -*- 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/>.
+#
+##############################################################################
+{
+    'name': 'Trial Balance per Period',
+    'version': '0.1',
+    'license': 'AGPL-3',
+    'author': 'Noviat',
+    'website': 'http://www.noviat.com',
+    'category' : 'Accounting & Finance',
+    'description': """
+This report generates an excel overview of the Trial Balance per Period.
+    """,
+    'depends': [
+        'account',
+        'report_xls'
+    ],
+    'data': [
+        'wizard/trial_balance_period_wizard.xml',
+    ],
+}
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added directory 'account_trial_balance_period_xls/doc'
=== added file 'account_trial_balance_period_xls/doc/doc.rst'
--- account_trial_balance_period_xls/doc/doc.rst	1970-01-01 00:00:00 +0000
+++ account_trial_balance_period_xls/doc/doc.rst	2014-06-21 15:52:31 +0000
@@ -0,0 +1,36 @@
+Differences with account_financial_report_webkit Trial Balance
+==============================================================
+
+This module is complementary to the 'account_financial_report_webkit'/'account_financial_report_webkit_xls' modules Trial Balance.
+
+Main differences:
+
+1) Main purpose of the report
+-----------------------------
+
+The main purpose of this report is to have a 'single click' view on the operational performance.
+If you select the top level P&L accounts and the periods, you get the P&L details as well as the summed up P&L results.
+
+2) Report by period
+-------------------
+
+The financial performance for the selected set of accounts is reported by fiscal period.
+In the last column the results of the fiscal periods are totalised.
+These totals are equal to the 'account_financial_report_webkit' totals (if opening entries are present, cf. infra).
+
+3) Initial Balance
+------------------
+
+This report collects his data via a query on the accounting entries per period.
+As a consequence, there is no 'Initial Balance' logic such as implemented in the 'account_financial_report_webkit' module.
+In order to include the 'Initial Balance' data in this report, you should first generate the opening entries for the selected fiscal year and include the Opening Period into the selected period range.
+By default the Opening & Close periods are excluded.
+
+4) Reporting Level
+------------------
+
+The report wizard allows to select a reporting level. 
+This level corresponds to the depth in the Chart of Accounts. 
+You can e.g. select level 1 to report only on the top level accounts (the general account classes).
+
+   
\ No newline at end of file

=== added file 'account_trial_balance_period_xls/doc/index.rst'
--- account_trial_balance_period_xls/doc/index.rst	1970-01-01 00:00:00 +0000
+++ account_trial_balance_period_xls/doc/index.rst	2014-06-21 15:52:31 +0000
@@ -0,0 +1,10 @@
+account_asset module documentation
+==================================
+
+Module Documentation
+''''''''''''''''''''
+
+.. toctree::
+   :maxdepth: 1
+
+   doc.rst

=== added directory 'account_trial_balance_period_xls/i18n'
=== added file 'account_trial_balance_period_xls/i18n/fr.po'
--- account_trial_balance_period_xls/i18n/fr.po	1970-01-01 00:00:00 +0000
+++ account_trial_balance_period_xls/i18n/fr.po	2014-06-21 15:52:31 +0000
@@ -0,0 +1,191 @@
+# French translation of OpenERP Server 6.1.
+# This file contains the translation of the following modules:
+#	* account_trial_balance_period_xls
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 6.1\n"
+"Report-Msgid-Bugs-To: support@xxxxxxxxx\n"
+"POT-Creation-Date: 2014-05-10 22:14:49.805000\n"
+"PO-Revision-Date: 2014-05-10 22:14:49.805000\n"
+"Last-Translator: Luc De Meyer (Noviat nv/sa)\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. module: account_trial_balance_period_xls
+#: model:ir.actions.act_window,name:account_trial_balance_period_xls.action_trial_balance_period_wizard
+msgid "Trial Balance by Period"
+msgstr "Balance des comptes par période"
+
+#. module: account_trial_balance_period_xls
+#: model:ir.ui.menu,name:account_trial_balance_period_xls.menu_trial_balance_period_wizard
+msgid "Trial Balance by Period"
+msgstr "Balance des comptes par période"
+
+#. module: account_trial_balance_period_xls
+#: field:trial.balance.period.wizard,chart_account_id:0
+msgid "Chart of Account"
+msgstr "Plan comptable"
+
+#. module: account_trial_balance_period_xls
+#: field:trial.balance.period.wizard,fiscalyear_id:0
+msgid "Fiscal Year"
+msgstr "Exercice fiscal"
+
+#. module: account_trial_balance_period_xls
+#: field:trial.balance.period.wizard,period_from:0
+msgid "Start Period"
+msgstr "Première période"
+
+#. module: account_trial_balance_period_xls
+#: field:trial.balance.period.wizard,period_to:0
+msgid "End Period"
+msgstr "Dernière période"
+
+#. module: account_trial_balance_period_xls
+#: field:trial.balance.period.wizard,target_move:0
+msgid "Target Moves"
+msgstr "Mouvements ciblés"
+
+#. module: account_trial_balance_period_xls
+#: selection:trial.balance.period.wizard,target_move:0
+msgid "All Posted Entries"
+msgstr "Toutes les écritures passées"
+
+#. module: account_trial_balance_period_xls
+#: selection:trial.balance.period.wizard,target_move:0
+msgid "All Entries"
+msgstr "Toutes les écritures"
+
+#. module: account_trial_balance_period_xls
+#: field:trial.balance.period.wizard,level:0
+msgid "Level"
+msgstr "Niveau"
+
+#. module: account_trial_balance_period_xls
+#: field:trial.balance.period.wizard,journal_ids:0
+msgid "Journals"
+msgstr "Journaux"
+
+#. module: account_trial_balance_period_xls
+#: field:trial.balance.period.wizard,account_ids:0
+msgid "Filter on accounts"
+msgstr "Filtre par compte"
+
+#. module: account_trial_balance_period_xls
+#: view:trial.balance.period.wizard:0
+msgid "Report Options"
+msgstr "Options du rapport"
+
+#. module: account_trial_balance_period_xls
+#: view:trial.balance.period.wizard:0
+msgid "Trial Balance per Period"
+msgstr "Balance des comptes par période"
+
+#. module: account_trial_balance_period_xls
+#: view:trial.balance.period.wizard:0
+msgid "Excel report of the Trial Balance per Period."
+msgstr "Rapport excel du balance des comptes par période."
+
+#. module: account_trial_balance_period_xls
+#: view:trial.balance.period.wizard:0
+msgid "Periods"
+msgstr "Périodes"
+
+#. module: account_trial_balance_period_xls
+#: view:trial.balance.period.wizard:0
+msgid "Journals"
+msgstr "Journaux"
+
+#. module: account_trial_balance_period_xls
+#: view:trial.balance.period.wizard:0
+msgid "Accounts"
+msgstr "Comptes"
+
+#. module: account_trial_balance_period_xls
+#: view:trial.balance.period.wizard:0
+msgid "Export only"
+msgstr "Exporter seulement"
+
+#. module: account_trial_balance_period_xls
+#: view:trial.balance.period.wizard:0
+msgid "Cancel"
+msgstr "Annuler"
+
+#. module: account_trial_balance_period_xls
+#: view:trial.balance.period.wizard:0
+msgid "Export"
+msgstr "Exporter"
+
+#. module: account_trial_balance_period_xls
+#: code:addons/account_trial_balance_period_xls/report/trial_balance_period_xls.py:10
+msgid "No records found for your selection!"
+msgstr "Aucun enregistrement trouvé pour votre sélection!"
+
+#. module: account_trial_balance_period_xls
+#: code:addons/account_trial_balance_period_xls/report/trial_balance_period_xls.py:11
+msgid "No Data Available"
+msgstr "Aucune donnée disponible"
+
+#. module: account_trial_balance_period_xls
+#: report:trial.balance.period.xls:0
+msgid "Fiscal Year"
+msgstr "Exercice fiscal"
+
+#. module: account_trial_balance_period_xls
+#: report:trial.balance.period.xls:0
+msgid "Trial Balance by Period"
+msgstr "Balance des comptes par période"
+
+#. module: account_trial_balance_period_xls
+#: report:trial.balance.period.xls:0
+msgid "All Posted Entries"
+msgstr "Toutes les écritures passées"
+
+#. module: account_trial_balance_period_xls
+#: report:trial.balance.period.xls:0
+msgid "All Entries"
+msgstr "Toutes les écritures"
+
+#. module: account_trial_balance_period_xls
+#: report:trial.balance.period.xls:0
+msgid "Totals"
+msgstr "Totaux"
+
+#. module: account_trial_balance_period_xls
+#: report:trial.balance.period.xls:0
+msgid "Code"
+msgstr "Code"
+
+#. module: account_trial_balance_period_xls
+#: report:trial.balance.period.xls:0
+msgid "Account"
+msgstr "Compte"
+
+#. module: account_trial_balance_period_xls
+#: report:trial.balance.period.xls:0
+msgid "Debit"
+msgstr "Débit"
+
+#. module: account_trial_balance_period_xls
+#: report:trial.balance.period.xls:0
+msgid "Credit"
+msgstr "Crédit"
+
+#. module: account_trial_balance_period_xls
+#: report:trial.balance.period.xls:0
+msgid "Balance"
+msgstr "Solde"
+
+#. module: account_trial_balance_period_xls
+#: report:trial.balance.period.xls:0
+msgid "Type"
+msgstr "Type"
+
+#. module: account_trial_balance_period_xls
+#: report:trial.balance.period.xls:0
+msgid "Level"
+msgstr "Niveau"
+

=== added file 'account_trial_balance_period_xls/i18n/nl.po'
--- account_trial_balance_period_xls/i18n/nl.po	1970-01-01 00:00:00 +0000
+++ account_trial_balance_period_xls/i18n/nl.po	2014-06-21 15:52:31 +0000
@@ -0,0 +1,191 @@
+# Dutch translation of OpenERP Server 6.1.
+# This file contains the translation of the following modules:
+#	* account_trial_balance_period_xls
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 6.1\n"
+"Report-Msgid-Bugs-To: support@xxxxxxxxx\n"
+"POT-Creation-Date: 2014-05-10 22:14:49.802000\n"
+"PO-Revision-Date: 2014-05-10 22:14:49.802000\n"
+"Last-Translator: Luc De Meyer (Noviat nv/sa)\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. module: account_trial_balance_period_xls
+#: model:ir.actions.act_window,name:account_trial_balance_period_xls.action_trial_balance_period_wizard
+msgid "Trial Balance by Period"
+msgstr "Proefbalans per periode"
+
+#. module: account_trial_balance_period_xls
+#: model:ir.ui.menu,name:account_trial_balance_period_xls.menu_trial_balance_period_wizard
+msgid "Trial Balance by Period"
+msgstr "Proefbalans per periode"
+
+#. module: account_trial_balance_period_xls
+#: field:trial.balance.period.wizard,chart_account_id:0
+msgid "Chart of Account"
+msgstr "Rekeningschema"
+
+#. module: account_trial_balance_period_xls
+#: field:trial.balance.period.wizard,fiscalyear_id:0
+msgid "Fiscal Year"
+msgstr "Boekjaar"
+
+#. module: account_trial_balance_period_xls
+#: field:trial.balance.period.wizard,period_from:0
+msgid "Start Period"
+msgstr "Beginperiode"
+
+#. module: account_trial_balance_period_xls
+#: field:trial.balance.period.wizard,period_to:0
+msgid "End Period"
+msgstr "Eindperiode"
+
+#. module: account_trial_balance_period_xls
+#: field:trial.balance.period.wizard,target_move:0
+msgid "Target Moves"
+msgstr "Boekingen"
+
+#. module: account_trial_balance_period_xls
+#: selection:trial.balance.period.wizard,target_move:0
+msgid "All Posted Entries"
+msgstr "Alle goedgekeurde boekingen"
+
+#. module: account_trial_balance_period_xls
+#: selection:trial.balance.period.wizard,target_move:0
+msgid "All Entries"
+msgstr "Alle boekingen"
+
+#. module: account_trial_balance_period_xls
+#: field:trial.balance.period.wizard,level:0
+msgid "Level"
+msgstr "Niveau"
+
+#. module: account_trial_balance_period_xls
+#: field:trial.balance.period.wizard,journal_ids:0
+msgid "Journals"
+msgstr "Dagboeken"
+
+#. module: account_trial_balance_period_xls
+#: field:trial.balance.period.wizard,account_ids:0
+msgid "Filter on accounts"
+msgstr "Filter per rekening"
+
+#. module: account_trial_balance_period_xls
+#: view:trial.balance.period.wizard:0
+msgid "Report Options"
+msgstr "Rapport opties"
+
+#. module: account_trial_balance_period_xls
+#: view:trial.balance.period.wizard:0
+msgid "Trial Balance per Period"
+msgstr "Proefbalans per periode"
+
+#. module: account_trial_balance_period_xls
+#: view:trial.balance.period.wizard:0
+msgid "Excel report of the Trial Balance per Period."
+msgstr "Excel rapport van de proefbalans per periode."
+
+#. module: account_trial_balance_period_xls
+#: view:trial.balance.period.wizard:0
+msgid "Periods"
+msgstr "Periodes"
+
+#. module: account_trial_balance_period_xls
+#: view:trial.balance.period.wizard:0
+msgid "Journals"
+msgstr "Dagboeken"
+
+#. module: account_trial_balance_period_xls
+#: view:trial.balance.period.wizard:0
+msgid "Accounts"
+msgstr "Rekeningen"
+
+#. module: account_trial_balance_period_xls
+#: view:trial.balance.period.wizard:0
+msgid "Export only"
+msgstr "Exporteer enkel"
+
+#. module: account_trial_balance_period_xls
+#: view:trial.balance.period.wizard:0
+msgid "Cancel"
+msgstr "Annuleer"
+
+#. module: account_trial_balance_period_xls
+#: view:trial.balance.period.wizard:0
+msgid "Export"
+msgstr "Exporteer"
+
+#. module: account_trial_balance_period_xls
+#: code:addons/account_trial_balance_period_xls/report/trial_balance_period_xls.py:10
+msgid "No records found for your selection!"
+msgstr "Geen records gevonden voor uw keuze!"
+
+#. module: account_trial_balance_period_xls
+#: code:addons/account_trial_balance_period_xls/report/trial_balance_period_xls.py:11
+msgid "No Data Available"
+msgstr "Geen gegevens beschikbaar"
+
+#. module: account_trial_balance_period_xls
+#: report:trial.balance.period.xls:0
+msgid "Fiscal Year"
+msgstr "Boekjaar"
+
+#. module: account_trial_balance_period_xls
+#: report:trial.balance.period.xls:0
+msgid "Trial Balance by Period"
+msgstr "Proefbalans per periode"
+
+#. module: account_trial_balance_period_xls
+#: report:trial.balance.period.xls:0
+msgid "All Posted Entries"
+msgstr "Alle goedgekeurde boekingen"
+
+#. module: account_trial_balance_period_xls
+#: report:trial.balance.period.xls:0
+msgid "All Entries"
+msgstr "Alle boekingen"
+
+#. module: account_trial_balance_period_xls
+#: report:trial.balance.period.xls:0
+msgid "Totals"
+msgstr "Totalen"
+
+#. module: account_trial_balance_period_xls
+#: report:trial.balance.period.xls:0
+msgid "Code"
+msgstr "Code"
+
+#. module: account_trial_balance_period_xls
+#: report:trial.balance.period.xls:0
+msgid "Account"
+msgstr "Rekening"
+
+#. module: account_trial_balance_period_xls
+#: report:trial.balance.period.xls:0
+msgid "Debit"
+msgstr "Debet"
+
+#. module: account_trial_balance_period_xls
+#: report:trial.balance.period.xls:0
+msgid "Credit"
+msgstr "Credit"
+
+#. module: account_trial_balance_period_xls
+#: report:trial.balance.period.xls:0
+msgid "Balance"
+msgstr "Saldo"
+
+#. module: account_trial_balance_period_xls
+#: report:trial.balance.period.xls:0
+msgid "Type"
+msgstr "Type"
+
+#. module: account_trial_balance_period_xls
+#: report:trial.balance.period.xls:0
+msgid "Level"
+msgstr "Niveau"
+

=== added directory 'account_trial_balance_period_xls/report'
=== added file 'account_trial_balance_period_xls/report/__init__.py'
--- account_trial_balance_period_xls/report/__init__.py	1970-01-01 00:00:00 +0000
+++ account_trial_balance_period_xls/report/__init__.py	2014-06-21 15:52:31 +0000
@@ -0,0 +1,26 @@
+# -*- 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/>.
+#
+##############################################################################
+
+import trial_balance_period_xls
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+

=== added file 'account_trial_balance_period_xls/report/trial_balance_period_xls.py'
--- account_trial_balance_period_xls/report/trial_balance_period_xls.py	1970-01-01 00:00:00 +0000
+++ account_trial_balance_period_xls/report/trial_balance_period_xls.py	2014-06-21 15:52:31 +0000
@@ -0,0 +1,533 @@
+# -*- 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/>.
+#
+##############################################################################
+
+import xlwt
+import time
+from datetime import datetime
+from openerp.osv import orm
+from openerp.report import report_sxw
+from openerp.addons.report_xls.report_xls import report_xls
+from openerp.addons.report_xls.utils import rowcol_to_cell, _render
+from openerp.tools.translate import translate, _
+import logging
+_logger = logging.getLogger(__name__)
+
+_ir_translation_name = 'trial.balance.period.xls'
+
+
+class trial_balance_period_xls_parser(report_sxw.rml_parse):
+
+    def __init__(self, cr, uid, name, context):
+        if context is None:
+            context = {}
+        super(trial_balance_period_xls_parser, self).__init__(cr, uid, name, context=context)
+        self.context = context
+        self.localcontext.update({
+            '_': self._,
+        })
+
+    def _(self, src):
+        lang = self.context.get('lang', 'en_US')
+        return translate(self.cr, _ir_translation_name, 'report', lang, src) or src
+
+    def _get_selection_label(self, object, field, val, context=None):
+        """ return label of selection list in language of the user """
+        field_dict = self.pool.get(object._name).fields_get(self.cr, self.uid, allfields=[field], context=context)
+        result_list = field_dict[field]['selection']
+        result = filter(lambda x: x[0] == val, result_list)[0][1]
+        return result
+
+    def _query_get(self, account, period, data):
+        query_start = "SELECT COALESCE(SUM(aml.debit), 0) AS debit, " \
+            "COALESCE(SUM(aml.credit), 0) AS credit " \
+            "FROM account_move_line aml " \
+            "INNER JOIN account_journal aj ON aml.journal_id = aj.id " \
+            "INNER JOIN account_move am ON aml.move_id = am.id " \
+            "INNER JOIN account_account aa ON aml.account_id = aa.id " \
+            "INNER JOIN account_period ap ON aml.period_id = ap.id " \
+            "WHERE aa.id = %s AND ap.id = %s " %(account.id, period.id)
+        if data['move_states'] == 'posted':
+            move_selection = "AND am.state = 'posted' "
+        else:
+            move_selection = ''
+        return query_start + move_selection
+
+    def set_context(self, objects, data, ids, report_type=None):
+        super(trial_balance_period_xls_parser, self).set_context(objects, data, ids)
+        cr = self.cr
+        uid = self.uid
+        context = self.context
+        _ = self._
+
+        acc_obj = self.pool.get('account.account')
+        company_obj = self.pool.get('res.company')
+        fy_obj = self.pool.get('account.fiscalyear')
+        period_obj = self.pool.get('account.period')
+
+        company_id = data['company_id']
+        company = company_obj.browse(cr, uid, company_id, context=context)
+        period_ids = data['period_ids']
+        fiscalyear_id = data['fiscalyear_id']
+        move_states = data['move_states']
+        level = data['level']
+
+        fiscalyear = fy_obj.browse(cr, uid, fiscalyear_id, context=context)
+        fy_code = fiscalyear.code
+        report_name = (' - ').join([
+            company.name,
+            _('Fiscal Year') + ' %s ' % fy_code,
+            _('Trial Balance by Period'),
+            move_states == ['posted'] and _('All Posted Entries') or _('All Entries'),
+            company.currency_id.name,
+            ])
+        periods = period_obj.browse(cr, uid, period_ids, context=context)
+
+        def _child_get(account):
+            """ get all (direct & indirect) children of an account """
+            accounts = []
+            for child in account.child_parent_ids:
+                accounts.append(child)
+                accounts += _child_get(child)
+            return accounts
+
+        accounts = []
+        for account in acc_obj.browse(cr, uid, ids, context):
+            accounts.append({
+                'account': account,
+                'children': _child_get(account),
+            })
+
+        accounts_data = []
+        for entry in accounts:
+            account = entry['account']
+            assert account.type == 'view', "Only accounts of type 'view' can be selected via the report selection screen."
+            account_data = {
+                'top': True,
+                'account': account,
+                'zeros': False,
+                'periods_data': [{'code': p.code} for p in periods]
+            }
+            accounts_data.append(account_data)
+
+            for account in entry['children']:
+                if account.type == 'view':
+                    zeros = False
+                else:
+                     zeros = True
+                account_data = {
+                    'account': account,
+                }
+                periods_data = []
+                for period in periods:
+                    period_data = {
+                        'code': period.code,
+                    }
+                    if account.type != 'view':
+                        cr.execute(self._query_get(account, period, data))
+                        res = cr.dictfetchone()
+                        debit = res['debit']
+                        credit = res['credit']
+                        period_data.update({
+                            'debit': debit,
+                            'credit': credit,
+                        })
+                        if debit or credit:
+                            zeros = False
+                    periods_data.append(period_data)
+                account_data.update({
+                    'periods_data': periods_data,
+                    'zeros': zeros
+                })
+                accounts_data.append(account_data)
+
+        # calculate view totals
+        def _total(x, p, field, total=0.0):
+            """ get sum(field) of the child accounts """
+            account_start = accounts_data[x]['account']
+            level_start = account_start.level
+            view_stack = [account_start]
+            for y, entry in enumerate(accounts_data[x + 1:], start=x + 1):
+                account = entry['account']
+                if account.level <= level_start:
+                    break
+                if account.type == 'view':
+                    if account.parent_id == view_stack[-1]:
+                        view_stack.append(account)
+                    elif account != view_stack[-1]:
+                        view_stack.pop()
+                        view_stack.append(account)                        
+                else:
+                    total += entry['periods_data'][p][field]
+            return total
+
+        for i, entry in enumerate(accounts_data):
+            account = entry['account']
+            if account.type == 'view':
+                zeros = True
+                for p, period_data in enumerate(entry['periods_data']):
+                    debit = _total(i, p, 'debit')
+                    credit = _total(i, p, 'credit')
+                    period_data['debit'] = debit
+                    period_data['credit'] = credit
+                    if debit or credit:
+                        zeros = False
+                entry['zeros'] = zeros
+
+        # remove 'zeros' entries and entries higher than wizard level
+        accounts_data = filter(lambda x: not x['zeros'], accounts_data)
+        if level:
+            accounts_data = filter(lambda x: x['account'].level <= level, accounts_data)
+        if not accounts_data:
+            raise orm.except_orm(_('No Data Available'), _('No records found for your selection!'))
+
+        # calculate relative child row positions
+        row_pos_table = dict((x, []) for x in range(len(accounts_data)))
+        for x, entry in enumerate(accounts_data):
+            account = entry['account']
+            if entry.get('top'):
+                level_stack = [(x, account)]
+            else:
+                if account.level > level_stack[-1][1].level and account.parent_id == level_stack[-1][1]:
+                    row_pos_table[level_stack[-1][0]].append(x - level_stack[-1][0])
+                    if account.type == 'view':
+                        level_stack.append((x, account))
+                else:
+                    if account.type == 'view':
+                        while level_stack[-1][1].level >= account.level:
+                            level_stack.pop()
+                        row_pos_table[level_stack[-1][0]].append(x - level_stack[-1][0])
+                        level_stack.append((x, account))
+
+        for x, entry in enumerate(accounts_data):
+            account = entry['account']
+            entry['account_type'] = self._get_selection_label(acc_obj, 'type', account.type, context)
+            if account.type == 'view':
+                entry['child_row_pos'] = row_pos_table[x]
+
+        accounts_data[-1].update({'last': True})
+
+        self.localcontext.update( {
+            'fy_code': fy_code,
+            'report_name': report_name,
+            'periods': periods,
+            'accounts_data': accounts_data,
+        })
+
+
+class trial_balance_period_xls(report_xls):
+
+    _column_size_acc_code = 12
+    _column_size_acc_name = 60
+    _column_size_values = 17
+    _column_size_type = 12
+    _column_size_level = 10
+
+    def __init__(self, name, table, rml=False, parser=False, header=True, store=False):
+        super(trial_balance_period_xls, self).__init__(name, table, rml, parser, header, store)
+
+        # Cell Styles
+        _xs = self.xls_styles
+        _xs.update({
+            'fill_grey': 'pattern: pattern solid, fore_color 22;',
+            'fill_blue': 'pattern: pattern solid, fore_color 27;',
+            'borders_all_black': 'borders: left thin, right thin, top thin, bottom thin;',
+            'borders_left_black': 'borders: left thin, right thin, top thin, bottom thin, '
+                'left_colour %s, right_colour %s, top_colour %s, bottom_colour %s;' %(0, self._bc, self._bc, self._bc),
+            'borders_right_black': 'borders: left thin, right thin, top thin, bottom thin, '
+                'left_colour %s, right_colour %s, top_colour %s, bottom_colour %s;' %(self._bc, 0, self._bc, self._bc),
+            'borders_left_right_black': 'borders: left thin, right thin, top thin, bottom thin, '
+                'left_colour %s, right_colour %s, top_colour %s, bottom_colour %s;' %(0, 0, self._bc, self._bc),                
+            'borders_top_black': 'borders: left thin, right thin, top thin, bottom thin, '
+                'left_colour %s, right_colour %s, top_colour %s, bottom_colour %s;' %(self._bc, self._bc, 0, self._bc),
+            'borders_bottom_black': 'borders: left thin, right thin, top thin, bottom thin, '
+                'left_colour %s, right_colour %s, top_colour %s, bottom_colour %s;' %(self._bc, self._bc, self._bc, 0),
+            'borders_left_top_black': 'borders: left thin, right thin, top thin, bottom thin, '
+                'left_colour %s, right_colour %s, top_colour %s, bottom_colour %s;' %(0, self._bc, 0, self._bc),
+            'borders_right_top_black': 'borders: left thin, right thin, top thin, bottom thin, '
+                'left_colour %s, right_colour %s, top_colour %s, bottom_colour %s;' %(self._bc, 0, 0, self._bc),
+            'borders_left_right_top_black': 'borders: left thin, right thin, top thin, bottom thin, '
+                'left_colour %s, right_colour %s, top_colour %s, bottom_colour %s;' %(0, 0, 0, self._bc),
+            'borders_left_bottom_black': 'borders: left thin, right thin, top thin, bottom thin, '
+                'left_colour %s, right_colour %s, top_colour %s, bottom_colour %s;' %(0, self._bc, self._bc, 0),
+            'borders_right_bottom_black': 'borders: left thin, right thin, top thin, bottom thin, '
+                'left_colour %s, right_colour %s, top_colour %s, bottom_colour %s;' %(self._bc, 0, self._bc, 0),
+            'borders_left_right_bottom_black': 'borders: left thin, right thin, top thin, bottom thin, '
+                'left_colour %s, right_colour %s, top_colour %s, bottom_colour %s;' %(0, 0, self._bc, 0),
+        })
+
+        # Period Header format
+        ph_cell_format = _xs['bold'] + _xs['fill_grey'] + _xs['borders_all_black']
+        self.ph_empty2_cell_style = xlwt.easyxf('borders: right thin, right_colour 0;')
+        self.ph_cell_style = xlwt.easyxf(ph_cell_format)
+        self.ph_cell_style_center = xlwt.easyxf(ph_cell_format + _xs['center'])
+
+        # Values Header format
+        vh_cell_format = _xs['bold'] + _xs['fill_blue']
+        self.vh_code_cell_style = xlwt.easyxf(vh_cell_format + _xs['borders_left_top_black'])
+        self.vh_account_cell_style = xlwt.easyxf(vh_cell_format + _xs['borders_right_top_black'])
+        self.vh_debit_cell_style = xlwt.easyxf(vh_cell_format + _xs['borders_left_top_black'] + _xs['right'])
+        self.vh_credit_cell_style = xlwt.easyxf(vh_cell_format + _xs['borders_top_black'] + _xs['right'])
+        self.vh_balance_cell_style = xlwt.easyxf(vh_cell_format + _xs['borders_right_top_black'] + _xs['right'])
+        self.vh_type_cell_style = xlwt.easyxf(vh_cell_format + _xs['borders_left_right_top_black'] + _xs['center'])
+        self.vh_level_cell_style = xlwt.easyxf(vh_cell_format + _xs['borders_left_right_top_black'] + _xs['center'])
+
+        # Column Data format for accounts of type View
+        av_cell_format = _xs['bold'] + _xs['fill']
+        self.av_code_cell_style = xlwt.easyxf(av_cell_format + _xs['borders_left_black'])
+        self.av_account_cell_style = xlwt.easyxf(av_cell_format + _xs['borders_right_black'])
+        self.av_debit_cell_style = xlwt.easyxf(av_cell_format + _xs['borders_left_black'] + _xs['right'], num_format_str = report_xls.decimal_format)
+        self.av_credit_cell_style = xlwt.easyxf(av_cell_format + _xs['borders_all'] + _xs['right'], num_format_str = report_xls.decimal_format)
+        self.av_balance_cell_style = xlwt.easyxf(av_cell_format + _xs['borders_right_black'] + _xs['right'], num_format_str = report_xls.decimal_format)
+        self.av_type_cell_style = xlwt.easyxf(av_cell_format + _xs['borders_left_right_black'] + _xs['center'])
+        self.av_level_cell_style = xlwt.easyxf(av_cell_format + _xs['borders_left_right_black'] + _xs['center'])
+        self.av_type_cell_style_last = xlwt.easyxf(av_cell_format + _xs['borders_left_right_bottom_black'] + _xs['center'])
+        self.av_level_cell_style_last = xlwt.easyxf(av_cell_format + _xs['borders_left_right_bottom_black'] + _xs['center'])
+
+        # Column Data format for regular accounts
+        self.ar_code_cell_style = xlwt.easyxf(_xs['borders_left_black'])
+        self.ar_account_cell_style = xlwt.easyxf(_xs['borders_right_black'])
+        self.ar_debit_cell_style = xlwt.easyxf(_xs['borders_left_black'] + _xs['right'], num_format_str = report_xls.decimal_format)
+        self.ar_credit_cell_style = xlwt.easyxf(_xs['borders_all'] + _xs['right'], num_format_str = report_xls.decimal_format)
+        self.ar_balance_cell_style = xlwt.easyxf(_xs['borders_right_black'] + _xs['right'], num_format_str = report_xls.decimal_format)
+        self.ar_type_cell_style = xlwt.easyxf(_xs['borders_left_right_black'] + _xs['center'])
+        self.ar_level_cell_style = xlwt.easyxf(_xs['borders_left_right_black'] + _xs['center'])
+        self.ar_type_cell_style_last = xlwt.easyxf(_xs['borders_left_right_bottom_black'] + _xs['center'])
+        self.ar_level_cell_style_last = xlwt.easyxf(_xs['borders_left_right_bottom_black'] + _xs['center'])
+
+        # totals
+        tot_cell_format = _xs['bold'] + _xs['fill_blue']
+        self.tot_code_cell_style = xlwt.easyxf(tot_cell_format + _xs['borders_left_bottom_black'])
+        self.tot_account_cell_style = xlwt.easyxf(tot_cell_format + _xs['borders_right_bottom_black'])
+        self.tot_debit_cell_style = xlwt.easyxf(tot_cell_format + _xs['borders_left_bottom_black'] + _xs['right'], num_format_str = report_xls.decimal_format)
+        self.tot_credit_cell_style = xlwt.easyxf(tot_cell_format + _xs['borders_bottom_black'] + _xs['right'], num_format_str = report_xls.decimal_format)
+        self.tot_balance_cell_style = xlwt.easyxf(tot_cell_format + _xs['borders_right_bottom_black'] + _xs['right'], num_format_str = report_xls.decimal_format)
+
+    def _tb_report_title(self, ws, _p, row_pos, xlwt, _xs):
+
+        cell_style = xlwt.easyxf(_xs['xls_title'])  
+        report_name = _p.report_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(ws, row_pos, row_data, row_style=cell_style)
+        
+        # write empty row to define column sizes
+        c_sizes = [self._column_size_acc_code, self._column_size_acc_name] + 3 * (len(_p.periods) + 1) * [self._column_size_values] + [self._column_size_type, self._column_size_level]
+        c_specs = [('empty%s'%i, 1, c_sizes[i], 'text', None) for i in range(0,len(c_sizes))]
+        row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
+        row_pos = self.xls_write_row(ws, row_pos, row_data, set_column_size=True)
+
+        return row_pos + 1
+
+    def _tb_periods_header(self, ws, _p, row_pos, xlwt, _xs):
+        _ = _p._
+        c_specs = [
+            ('empty1', 1, 0, 'text', None),
+            ('empty2', 1, 0, 'text', None, None, self.ph_empty2_cell_style),
+        ]
+        for p in _p.periods:
+            c_specs.append((p.code, 3, 0, 'text', p.code, None, self.ph_cell_style_center))
+        c_specs.append(('totals', 3, 0, 'text', _("Totals"), None, self.ph_cell_style_center))
+        row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
+        row_pos = self.xls_write_row(ws, row_pos, row_data)
+        return row_pos
+
+    def _tb_values_header(self, ws, _p, row_pos, xlwt, _xs):
+        _ = _p._
+        c_specs = [
+            ('code', 1, 0, 'text', _("Code"), None, self.vh_code_cell_style),
+            ('account', 1, 0, 'text', _("Account"), None, self.vh_account_cell_style),
+        ]
+        for i in range(len(_p.periods) + 1):
+            c_specs += [
+                    ('debit%s' %i, 1, 0, 'text', _("Debit"), None, self.vh_debit_cell_style),
+                    ('credit%s' %i, 1, 0, 'text', _("Credit"), None, self.vh_credit_cell_style),
+                    ('balance%s' %i, 1, 0, 'text', _("Balance"), None, self.vh_balance_cell_style),
+            ]
+        c_specs += [
+            ('type', 1, 0, 'text', _("Type"), None, self.vh_type_cell_style),
+            ('level', 1, 0, 'text', _("Level"), None, self.vh_level_cell_style),
+        ]
+        row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
+        row_pos = self.xls_write_row(ws, row_pos, row_data)
+        ws.set_vert_split_pos(2)
+        ws.set_horz_split_pos(row_pos)
+        return row_pos
+
+    def _tb_account_data(self, ws, _p, row_pos, xlwt, _xs, entry):
+        account = entry['account']
+        
+        av_style = account.type == 'view' and True or False
+        if av_style:
+            code_cell_style = self.av_code_cell_style
+            account_cell_style = self.av_account_cell_style
+            debit_cell_style = self.av_debit_cell_style
+            credit_cell_style = self.av_credit_cell_style
+            balance_cell_style = self.av_balance_cell_style
+            type_cell_style = entry.get('last') and self.av_type_cell_style_last or self.av_type_cell_style
+            level_cell_style = entry.get('last') and self.av_level_cell_style_last or self.av_level_cell_style
+        else:
+            code_cell_style = self.ar_code_cell_style
+            account_cell_style = self.ar_account_cell_style
+            debit_cell_style = self.ar_debit_cell_style
+            credit_cell_style = self.ar_credit_cell_style
+            balance_cell_style = self.ar_balance_cell_style
+            type_cell_style = entry.get('last') and self.ar_type_cell_style_last or self.ar_type_cell_style
+            level_cell_style = entry.get('last') and self.ar_level_cell_style_last or self.ar_level_cell_style
+
+        if entry.get('child_row_pos'):
+            child_row_pos = [row_pos + p for p in entry['child_row_pos']]
+            c_specs = [
+                ('code', 1, 0, 'text', account.code, None, code_cell_style),
+                ('account', 1, 0, 'text', account.name, None, account_cell_style),
+            ]
+            for i, vals in enumerate(entry['periods_data']):
+                debit_pos = 2 + i * 3
+                credit_pos = debit_pos + 1
+                debit_cell = rowcol_to_cell(row_pos, debit_pos)
+                credit_cell = rowcol_to_cell(row_pos, credit_pos)
+                bal_formula = debit_cell + '-' + credit_cell
+                if i == 0:
+                    debit_total_formula = debit_cell
+                    credit_total_formula = credit_cell
+                else:
+                    debit_total_formula += '+' + debit_cell
+                    credit_total_formula += '+' + credit_cell
+                child_debit_cells = [rowcol_to_cell(p, debit_pos) for p in child_row_pos]
+                debit_formula = '+'.join(child_debit_cells)
+                child_credit_cells = [rowcol_to_cell(p, credit_pos) for p in child_row_pos]
+                credit_formula = '+'.join(child_credit_cells)
+                c_specs += [
+                        ('debit%s' %i, 1, 0, 'number', None, debit_formula, debit_cell_style),
+                        ('credit%s' %i, 1, 0, 'number', None, credit_formula, credit_cell_style),
+                        ('balance%s' %i, 1, 0, 'number', None, bal_formula, balance_cell_style),
+                ]
+            debit_pos += 3
+            credit_pos = debit_pos + 1
+            debit_cell = rowcol_to_cell(row_pos, debit_pos)
+            credit_cell = rowcol_to_cell(row_pos, credit_pos)
+            bal_formula = debit_cell + '-' + credit_cell
+            c_specs += [
+                    ('total_debit%s' %i, 1, 0, 'number', None, debit_total_formula, debit_cell_style),
+                    ('total_credit%s' %i, 1, 0, 'number', None, credit_total_formula, credit_cell_style),
+                    ('total_balance%s' %i, 1, 0, 'number', None, bal_formula, balance_cell_style),
+            ]
+            c_specs += [
+                ('type', 1, 0, 'text', entry['account_type'], None, type_cell_style),
+                ('level', 1, 0, 'number', account.level, None, level_cell_style),
+            ]
+        else:
+            c_specs = [
+                ('code', 1, 0, 'text', account.code, None, code_cell_style),
+                ('account', 1, 0, 'text', account.name, None, account_cell_style),
+            ]
+            for i, vals in enumerate(entry['periods_data']):
+                debit_pos = 2 + i * 3
+                credit_pos = debit_pos + 1
+                debit_cell = rowcol_to_cell(row_pos, debit_pos)
+                credit_cell = rowcol_to_cell(row_pos, credit_pos)
+                bal_formula = debit_cell + '-' + credit_cell
+                if i == 0:
+                    debit_total_formula = debit_cell
+                    credit_total_formula = credit_cell
+                else:
+                    debit_total_formula += '+' + debit_cell
+                    credit_total_formula += '+' + credit_cell
+                c_specs += [
+                        ('debit%s' %i, 1, 0, 'number', vals['debit'], None, debit_cell_style),
+                        ('credit%s' %i, 1, 0, 'number', vals['credit'], None, credit_cell_style),
+                        ('balance%s' %i, 1, 0, 'number', None, bal_formula, balance_cell_style),
+                ]
+            debit_pos += 3
+            credit_pos = debit_pos + 1
+            debit_cell = rowcol_to_cell(row_pos, debit_pos)
+            credit_cell = rowcol_to_cell(row_pos, credit_pos)
+            bal_formula = debit_cell + '-' + credit_cell
+            c_specs += [
+                    ('total_debit%s' %i, 1, 0, 'number', None, debit_total_formula, debit_cell_style),
+                    ('total_credit%s' %i, 1, 0, 'number', None, credit_total_formula, credit_cell_style),
+                    ('total_balance%s' %i, 1, 0, 'number', None, bal_formula, balance_cell_style),
+            ]
+            c_specs += [
+                ('type', 1, 0, 'text', entry['account_type'], None, type_cell_style),
+                ('level', 1, 0, 'number', account.level, None, level_cell_style),
+            ]
+        row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
+        row_pos = self.xls_write_row(ws, row_pos, row_data)
+        return row_pos
+
+    def _tb_account_totals(self, ws, _p, row_pos, xlwt, _xs, totals_row_pos):
+        c_specs = [
+            ('code', 1, 0, 'text', None, None, self.tot_code_cell_style),
+            ('account', 1, 0, 'text', None, None, self.tot_account_cell_style),
+        ]
+        for i in range(len(_p.periods) + 1):
+            debit_pos = 2 + i * 3
+            credit_pos = debit_pos + 1
+            debit_cell = rowcol_to_cell(row_pos, debit_pos)
+            credit_cell = rowcol_to_cell(row_pos, credit_pos)
+            bal_formula = debit_cell + '-' + credit_cell
+            debit_total_formula = '+'.join([rowcol_to_cell(p, debit_pos) for p in totals_row_pos])
+            credit_total_formula = '+'.join([rowcol_to_cell(p, credit_pos) for p in totals_row_pos])
+            c_specs += [
+                    ('debit%s' %i, 1, 0, 'number', None, debit_total_formula, self.tot_debit_cell_style),
+                    ('credit%s' %i, 1, 0, 'number', None, credit_total_formula, self.tot_credit_cell_style),
+                    ('balance%s' %i, 1, 0, 'number', None, bal_formula, self.tot_balance_cell_style),
+            ]
+        row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
+        row_pos = self.xls_write_row(ws, row_pos, row_data)
+        return row_pos
+
+    def generate_xls_report(self, _p, _xs, data, objects, wb):
+
+        sheet_name = _p.fy_code[:31].replace('/', '-')
+        ws = wb.add_sheet(sheet_name)
+        ws.panes_frozen = True
+        ws.remove_splits = True
+        ws.portrait = 0  # Landscape
+        ws.fit_width_to_pages = 1
+        row_pos = 0
+
+        # set print header/footer
+        ws.header_str = self.xls_headers['standard']
+        ws.footer_str = self.xls_footers['standard']
+
+        # Header
+        row_pos = self._tb_report_title(ws, _p, row_pos, xlwt, _xs)
+        row_pos = self._tb_periods_header(ws, _p, row_pos, xlwt, _xs)
+        row_pos = self._tb_values_header(ws, _p, row_pos, xlwt, _xs)
+
+        # Data
+        totals_row_pos = []
+        for entry in _p.accounts_data:
+            if entry.get('top'):
+                totals_row_pos.append(row_pos)
+            row_pos = self._tb_account_data(ws, _p, row_pos, xlwt, _xs, entry)
+
+        # Totals
+        row_pos = self._tb_account_totals(ws, _p, row_pos, xlwt, _xs, totals_row_pos)
+
+trial_balance_period_xls('report.account.trial.balance.period.xls', 'account.journal',
+    parser=trial_balance_period_xls_parser)
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added directory 'account_trial_balance_period_xls/static'
=== added directory 'account_trial_balance_period_xls/static/src'
=== added directory 'account_trial_balance_period_xls/static/src/img'
=== added file 'account_trial_balance_period_xls/static/src/img/icon.png'
Binary files account_trial_balance_period_xls/static/src/img/icon.png	1970-01-01 00:00:00 +0000 and account_trial_balance_period_xls/static/src/img/icon.png	2014-06-21 15:52:31 +0000 differ
=== added directory 'account_trial_balance_period_xls/wizard'
=== added file 'account_trial_balance_period_xls/wizard/__init__.py'
--- account_trial_balance_period_xls/wizard/__init__.py	1970-01-01 00:00:00 +0000
+++ account_trial_balance_period_xls/wizard/__init__.py	2014-06-21 15:52:31 +0000
@@ -0,0 +1,25 @@
+# -*- 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/>.
+#
+##############################################################################
+
+from . import trial_balance_period_wizard
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'account_trial_balance_period_xls/wizard/trial_balance_period_wizard.py'
--- account_trial_balance_period_xls/wizard/trial_balance_period_wizard.py	1970-01-01 00:00:00 +0000
+++ account_trial_balance_period_xls/wizard/trial_balance_period_wizard.py	2014-06-21 15:52:31 +0000
@@ -0,0 +1,155 @@
+# -*- 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/>.
+#
+##############################################################################
+
+from openerp.tools.translate import _
+from openerp.osv import orm, fields
+import time
+import logging
+_logger = logging.getLogger(__name__)
+
+
+class account_trial_balance_period_wizard(orm.TransientModel):
+    _name = 'trial.balance.period.wizard'
+    _description = 'Trial Balance per Period'
+
+    _columns = {
+        'chart_account_id': fields.many2one('account.account', 'Chart of Account',
+            help='Select Charts of Accounts', required=True, domain = [('parent_id','=',False)]),
+        'company_id': fields.related('chart_account_id', 'company_id', type='many2one', 
+            relation='res.company', string='Company', readonly=True),
+        'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscal Year', required=True),
+        'period_from': fields.many2one('account.period', 'Start Period', required=True),
+        'period_to': fields.many2one('account.period', 'End Period', required=True),
+        'target_move': fields.selection([
+            ('posted', 'All Posted Entries'),
+            ('all', 'All Entries'),
+            ], 'Target Moves', required=True),
+        'level': fields.integer('Level',
+            help="Specify the account level to include in the report.\n"
+                 "Specify '0' to show details of all selected accounts as well as it's child accounts."),
+        'journal_ids': fields.many2many('account.journal', string='Journals',
+            help="Only entries from selected journals will be printed."),
+        'account_ids': fields.many2many('account.account', string='Filter on accounts',
+            help="Only selected accounts will be printed."),
+        }
+
+    def _get_account(self, cr, uid, context=None):
+        accounts = self.pool.get('account.account').search(cr, uid, [('parent_id', '=', False)], limit=1)
+        return accounts and accounts[0] or False
+
+    def _get_all_journals(self, cr, uid, context=None):
+        return self.pool.get('account.journal').search(cr, uid ,[])
+
+    def _get_fiscalyear(self, cr, uid, context=None):
+        now = time.strftime('%Y-%m-%d')
+        fiscalyears = self.pool.get('account.fiscalyear').search(cr, uid, [('date_start', '<', now), ('date_stop', '>', now)], limit=1 )
+        return fiscalyears and fiscalyears[0] or False
+
+    _defaults = {
+        'fiscalyear_id': _get_fiscalyear,
+        'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.common.report',context=c),
+        'chart_account_id': _get_account,
+        'target_move': 'posted',
+    }
+
+    def onchange_chart_id(self, cr, uid, ids, chart_account_id=False, context=None):
+        if chart_account_id:
+            company_id = self.pool.get('account.account').browse(cr, uid, chart_account_id, context=context).company_id.id
+        return {'value': {'company_id': company_id}}
+
+    def fy_period_ids(self, cr, uid, fiscalyear_id):
+        """ returns all periods from a fiscalyear sorted by date """
+        fy_period_ids = []
+        cr.execute("SELECT id FROM account_period "
+            "WHERE fiscalyear_id=%s AND NOT special "
+            "ORDER BY date_start",
+            (fiscalyear_id,))
+        res = cr.fetchall()
+        if res:
+            fy_period_ids = map(lambda x: x[0], res)
+        return fy_period_ids
+
+    def onchange_fiscalyear_id(self, cr, uid, ids, fiscalyear_id=False, context=None):
+        res = {'value': {}}
+        fy_period_ids = self.fy_period_ids(cr, uid, fiscalyear_id)
+        if fy_period_ids:
+            res['value']['period_from'] = fy_period_ids[0]
+            res['value']['period_to'] = fy_period_ids[-1]
+        return res
+
+    def xls_export(self, cr, uid, ids, context=None):
+        if context is None:
+            context = {}
+        move_obj = self.pool.get('account.move')
+        wiz_form = self.browse(cr, uid, ids)[0]
+        fiscalyear_id = wiz_form.fiscalyear_id.id
+        company_id = wiz_form.company_id.id
+        period_from = wiz_form.period_from
+        period_to = wiz_form.period_to
+        if period_from.date_start > period_to.date_start:
+            raise orm.except_orm(_('Error'), 
+                _('The Start Period must precede the End Period !'))
+        cr.execute("SELECT id FROM account_period "
+            "WHERE date_start>=%s AND date_stop<=%s AND company_id=%s AND NOT special "
+            "ORDER BY date_start",
+            (period_from.date_start, period_to.date_stop, company_id))
+        period_ids = map(lambda x: x[0], cr.fetchall())
+        if period_from.special:
+            period_ids.insert(0, period_from.id)
+        if period_to.special:
+            period_ids.append(period_to.id)
+        if wiz_form.journal_ids:
+            journal_ids = [j.id for j in wiz_form.journal_ids]
+        else:
+            journal_ids = self._get_all_journals(cr, uid)
+        if wiz_form.target_move == 'posted':
+            move_states = ['posted']
+        else:
+            move_states = ['draft','posted']
+        if wiz_form.account_ids:
+            accounts = []
+            for account in wiz_form.account_ids:
+                if account.parent_id in accounts:
+                    continue
+                else:
+                    accounts.append(account)
+            account_ids = [a.id for a in accounts]
+        else:
+            account_ids = [wiz_form.chart_account_id.id]
+
+        datas = {
+            'model': 'account.account',
+            'ids': account_ids,
+            'journal_ids': journal_ids,
+            'company_id': company_id,
+            'period_ids': period_ids,
+            'fiscalyear_id': fiscalyear_id,
+            'move_states': move_states,
+            'level': wiz_form.level,
+            'account_ids': account_ids,
+        }
+
+        return {'type': 'ir.actions.report.xml',
+            'report_name': 'account.trial.balance.period.xls',
+            'datas': datas}
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'account_trial_balance_period_xls/wizard/trial_balance_period_wizard.xml'
--- account_trial_balance_period_xls/wizard/trial_balance_period_wizard.xml	1970-01-01 00:00:00 +0000
+++ account_trial_balance_period_xls/wizard/trial_balance_period_wizard.xml	2014-06-21 15:52:31 +0000
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+  <data>
+
+    <record id="trial_balance_period_wizard_view" model="ir.ui.view">
+      <field name="name">Trial Balance per Period</field>
+      <field name="model">trial.balance.period.wizard</field>
+      <field name="arch" type="xml">
+        <form string="Report Options" version="7.0">
+          <label nolabel="1" colspan="4" string="Excel report of the Trial Balance per Period."/>
+          <group col="4" colspan="4">
+            <field name="chart_account_id" widget="selection" on_change="onchange_chart_id(chart_account_id, context)"/>
+            <field name="company_id" invisible="1"/>
+            <field name="fiscalyear_id" domain="[('company_id','=',company_id)]" on_change="onchange_fiscalyear_id(fiscalyear_id, context)"/>
+            <field name="target_move"/>
+            <field name="level"/>
+          </group>
+          <group string="Periods" colspan="4">
+            <field name="period_from" domain="[('fiscalyear_id', '=', fiscalyear_id)]" colspan="4"/>
+            <field name="period_to" domain="[('fiscalyear_id', '=', fiscalyear_id)]" colspan="4"/>
+          </group>
+          <notebook tabpos="up" colspan="4">
+            <page string="Journals" name="journal_ids">
+              <field name="journal_ids" colspan="4" nolabel="1"/>
+            </page>
+            <page string="Accounts" name="account_ids">
+              <label string="Export only"/>
+              <field name="account_ids" domain="[('type', '=', 'view'), ('parent_id', '!=', False), ('level', '&lt;', level==0 and 999 or level+1), ('id', 'child_of', [chart_account_id])]" colspan="4" nolabel="1">
+                <tree>
+                  <field name="code"/>
+                  <field name="name"/>
+                  <field name="type"/>
+                </tree>
+              </field>
+            </page>
+          </notebook>
+          <footer>
+            <button name="xls_export" icon="gtk-execute" string="Export" type="object" context="{'xls_export':1}" default_focus="1" class="oe_highlight"/>
+            or
+            <button string="Cancel" class="oe_link" special="cancel" />
+          </footer>
+        </form>
+      </field>
+    </record>
+
+    <record id="action_trial_balance_period_wizard" model="ir.actions.act_window">
+      <field name="name">Trial Balance per Period</field>
+      <field name="type">ir.actions.act_window</field>
+      <field name="res_model">trial.balance.period.wizard</field>
+      <field name="view_type">form</field>
+      <field name="view_mode">form</field>
+      <field name="view_id" ref="trial_balance_period_wizard_view"/>
+      <field name="target">new</field>
+    </record>
+
+    <menuitem
+      name="Trial Balance per Period"
+      sequence="10"
+      parent="account.final_accounting_reports"
+      action="action_trial_balance_period_wizard"
+      id="menu_trial_balance_period_wizard"
+      icon="STOCK_PRINT"/>
+
+  </data>
+</openerp>
\ No newline at end of file


Follow ups