From 4e2b55ce94236a08bd6490f71ee32a67ff4bd9e4 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Wed, 22 Oct 2008 18:30:47 +0530 Subject: [PATCH] open report central journal using wizard (F.M->legal statements->generic reports) bzr revid: mra@tinyerp.com-20081022130047-ee3tcmb21g33ephg --- addons/account/account_wizard.xml | 7 +- addons/account/report/central_journal.py | 23 +- .../account/report/wizard_central_journal.rml | 247 ++++++++++++++++++ addons/account/wizard/__init__.py | 1 + .../account/wizard/wizard_central_journal.py | 60 +++++ addons/account/wizard/wizard_print_journal.py | 5 +- 6 files changed, 332 insertions(+), 11 deletions(-) create mode 100644 addons/account/report/wizard_central_journal.rml create mode 100644 addons/account/wizard/wizard_central_journal.py diff --git a/addons/account/account_wizard.xml b/addons/account/account_wizard.xml index 96a2c417739..01a7f2759dd 100644 --- a/addons/account/account_wizard.xml +++ b/addons/account/account_wizard.xml @@ -86,8 +86,11 @@ - - + + + + + diff --git a/addons/account/report/central_journal.py b/addons/account/report/central_journal.py index 7b595a311a7..35cd4f83f30 100644 --- a/addons/account/report/central_journal.py +++ b/addons/account/report/central_journal.py @@ -43,20 +43,33 @@ class journal_print(report_sxw.rml_parse): 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit }) - + def lines(self, period_id, journal_id, *args): + if type(period_id)==type([]): + ids_final = [] + for journal in journal_id: + for period in period_id: + ids_journal_period = self.pool.get('account.journal.period').search(self.cr,self.uid, [('journal_id','=',journal),('period_id','=',period)]) + if ids_journal_period: + self.cr.execute('select a.code, a.name, sum(debit) as debit, sum(credit) as credit from account_move_line l left join account_account a on (l.account_id=a.id) where l.period_id=%d and l.journal_id=%d and l.state<>\'draft\' group by a.id, a.code, a.name, l.journal_id, l.period_id', (period, journal)) + res = self.cr.dictfetchall() + a = {'journal':self.pool.get('account.journal').browse(self.cr, self.uid, journal),'period':self.pool.get('account.period').browse(self.cr, self.uid, period)} + res[0].update(a) + ids_final.append(res) + return ids_final self.cr.execute('select a.code, a.name, sum(debit) as debit, sum(credit) as credit from account_move_line l left join account_account a on (l.account_id=a.id) where l.period_id=%d and l.journal_id=%d and l.state<>\'draft\' group by a.id, a.code, a.name', (period_id, journal_id)) - return self.cr.dictfetchall() - + res = self.cr.dictfetchall() + return res + def _sum_debit(self, period_id, journal_id): self.cr.execute('select sum(debit) from account_move_line where period_id=%d and journal_id=%d and state<>\'draft\'', (period_id, journal_id)) return self.cr.fetchone()[0] or 0.0 - + def _sum_credit(self, period_id, journal_id): self.cr.execute('select sum(credit) from account_move_line where period_id=%d and journal_id=%d and state<>\'draft\'', (period_id, journal_id)) return self.cr.fetchone()[0] or 0.0 report_sxw.report_sxw('report.account.central.journal', 'account.journal.period', 'addons/account/report/central_journal.rml',parser=journal_print, header=False) - +report_sxw.report_sxw('report.account.central.journal.wiz', 'account.journal.period', 'addons/account/report/wizard_central_journal.rml',parser=journal_print, header=False) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/wizard_central_journal.rml b/addons/account/report/wizard_central_journal.rml new file mode 100644 index 00000000000..4c0b037971a --- /dev/null +++ b/addons/account/report/wizard_central_journal.rml @@ -0,0 +1,247 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [[ repeatIn(objects, 'o') ]] + [[ repeatIn(lines(data['form']['period_id'][0][2],data['form']['journal_id'][0][2]), 'line') ]] + + + + Journal Code + + + Journal Name + + + Printing Date + + + + + + + [[ line[0]['journal'].code or '' ]] + + + [[ line[0]['journal'].name ]] + + + [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S') ]] + + + + + + + + + + + + + Account Num. + + + Account Name + + + Debit + + + Credit + + + + + + + + + Total: + + + + + + + + [[ '%.2f' % sum_debit(line[0]['period'].id, line[0]['journal'].id) ]] + + + [[ '%.2f' % sum_credit(line[0]['period'].id, line[0]['journal'].id) ]] + + + + + + + + + + [[repeatIn(line,'l')]] + + + [[ l['code'] ]] + + + [[ l['name'] ]] + + + [[ formatLang(l['debit']) and '%.2f' % l['debit'] or '0.00' ]] + + + [[ formatLang(l['credit']) and '%.2f' % l['credit'] or '0.00' ]] + + + + + + + + + + + diff --git a/addons/account/wizard/__init__.py b/addons/account/wizard/__init__.py index 3cae8e78a95..5a434c54cd2 100644 --- a/addons/account/wizard/__init__.py +++ b/addons/account/wizard/__init__.py @@ -65,6 +65,7 @@ import wizard_state_open import wizard_statement_from_invoice import wizard_print_journal +import wizard_central_journal # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/wizard_central_journal.py b/addons/account/wizard/wizard_central_journal.py new file mode 100644 index 00000000000..2c41ad252a5 --- /dev/null +++ b/addons/account/wizard/wizard_central_journal.py @@ -0,0 +1,60 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved. +# +# $Id$ +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +import wizard +import pooler + +form = ''' +
+ + +''' + +fields = { + 'journal_id': {'string': 'Journal', 'type': 'many2many', 'relation': 'account.journal', 'required': True}, + 'period_id': {'string': 'Period', 'type': 'many2many', 'relation': 'account.period', 'required': True}, +} + + +class wizard_print_journal(wizard.interface): + states = { + 'init': { + 'actions': [], + 'result': {'type': 'form', 'arch': form, 'fields': fields, 'state': (('end', 'Cancel'), ('print', 'Print'))}, + }, + 'print': { + 'actions': [], + 'result': {'type':'print', 'report':'account.central.journal.wiz', 'state':'end'}, + }, + } +wizard_print_journal('account.central.journal.report') + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/account/wizard/wizard_print_journal.py b/addons/account/wizard/wizard_print_journal.py index d9440a8a231..c288e096dee 100644 --- a/addons/account/wizard/wizard_print_journal.py +++ b/addons/account/wizard/wizard_print_journal.py @@ -51,9 +51,6 @@ fields = { } -def print_journal(self, cr, uid, data, context): - return {} - class wizard_print_journal(wizard.interface): states = { 'init': { @@ -61,7 +58,7 @@ class wizard_print_journal(wizard.interface): 'result': {'type': 'form', 'arch': form, 'fields': fields, 'state': (('end', 'Cancel'), ('print', 'Print'))}, }, 'print': { - 'actions': [print_journal], + 'actions': [], 'result': {'type':'print', 'report':'account.journal.period.print.wiz', 'state':'end'}, }, }