diff options
| author | Mustufa Rangwala <mra@tinyerp.com> | 2008-10-22 18:30:47 +0530 |
|---|---|---|
| committer | Mustufa Rangwala <mra@tinyerp.com> | 2008-10-22 18:30:47 +0530 |
| commit | 4e2b55ce94236a08bd6490f71ee32a67ff4bd9e4 (patch) | |
| tree | 9ecc927501ed82bb447ee2c9dedb6ac90aa04055 | |
| parent | 8e5ef87920c0f7ab95190ed71f5e67c73c75654c (diff) | |
open report central journal using wizard (F.M->legal statements->generic reports)
bzr revid: mra@tinyerp.com-20081022130047-ee3tcmb21g33ephg
| -rw-r--r-- | addons/account/account_wizard.xml | 7 | ||||
| -rw-r--r-- | addons/account/report/central_journal.py | 23 | ||||
| -rw-r--r-- | addons/account/report/wizard_central_journal.rml | 247 | ||||
| -rw-r--r-- | addons/account/wizard/__init__.py | 1 | ||||
| -rw-r--r-- | addons/account/wizard/wizard_central_journal.py | 60 | ||||
| -rw-r--r-- | addons/account/wizard/wizard_print_journal.py | 5 |
6 files changed, 332 insertions, 11 deletions
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 @@ <wizard id="wizard_general_ledger" menu="False" model="account.account" name="account.general.ledger.report" string="General ledger"/> <menuitem icon="STOCK_PRINT" action="wizard_general_ledger" id="menu_general_ledger" parent="account.menu_generic_report" type="wizard"/> - <wizard id="wizard_print_journal" menu="False" model="account.journal.period" name="account.print.journal.report" string="Print journal"/> - <menuitem icon="STOCK_PRINT" action="wizard_print_journal" id="menu_print_journal" parent="account.menu_generic_report" type="wizard"/> + <wizard id="wizard_print_journal" menu="False" model="account.journal.period" name="account.print.journal.report" string="Print journal" /> + <menuitem icon="STOCK_PRINT" action="wizard_print_journal" id="menu_print_journal" parent="account.menu_generic_report" type="wizard" /> + + <wizard id="wizard_central_journal" menu="False" model="account.journal.period" name="account.central.journal.report" string="Central journal" /> + <menuitem icon="STOCK_PRINT" action="wizard_central_journal" id="menu_cetral_journal" parent="account.menu_generic_report" type="wizard" /> </data> 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 @@ +<?xml version="1.0"?> +<document filename="test.pdf"> + <template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20"> + <pageTemplate id="first"> + <frame id="first" x1="57.0" y1="57.0" width="481" height="728"/> + <header> + <pageGraphics> + <setFont name="Helvetica-Bold" size="9"/> + + + <!--COL 1--> + <drawString x="1.0cm" y="28.1cm">[[ company.name ]]</drawString> + <drawRightString x="20cm" y="28.1cm">Central Journal-[[ company.currency_id.name ]]</drawRightString> + + <!-- Header --> + + + <setFont name="Helvetica" size="9"/> + <drawString x="1.0cm" y="1cm"> [[ time.strftime("%Y-%m-%d %H:%M", time.localtime()) ]]</drawString> + <drawString x="19.0cm" y="1cm">Page <pageNumber/></drawString> + <!--<drawRightString x="19.8cm" y="28cm">[[ company.rml_header1 ]]</drawRightString>--> + + + <lineMode width="0.7"/> + <lines>1cm 27.7cm 20cm 27.7cm</lines> + <setFont name="Helvetica" size="8"/> + + </pageGraphics> + </header> + </pageTemplate> + </template> + <stylesheet> + <blockTableStyle id="Standard_Outline"> + <blockAlignment value="LEFT"/> + <blockValign value="TOP"/> + </blockTableStyle> + <blockTableStyle id="Table_header_Content"> + <blockAlignment value="LEFT"/> + <blockValign value="TOP"/> + </blockTableStyle> + <blockTableStyle id="Table_Sub_Header_Content"> + <blockAlignment value="LEFT"/> + <blockValign value="TOP"/> + <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="0,0" stop="0,-1"/> + <lineStyle kind="LINEABOVE" colorName="#cccccc" start="0,0" stop="0,0"/> + <lineStyle kind="LINEBELOW" colorName="#cccccc" start="0,-1" stop="0,-1"/> + <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="1,0" stop="1,-1"/> + <lineStyle kind="LINEABOVE" colorName="#cccccc" start="1,0" stop="1,0"/> + <lineStyle kind="LINEBELOW" colorName="#cccccc" start="1,-1" stop="1,-1"/> + <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="2,0" stop="2,-1"/> + <lineStyle kind="LINEAFTER" colorName="#cccccc" start="2,0" stop="2,-1"/> + <lineStyle kind="LINEABOVE" colorName="#cccccc" start="2,0" stop="2,0"/> + <lineStyle kind="LINEBELOW" colorName="#cccccc" start="2,-1" stop="2,-1"/> + </blockTableStyle> + <blockTableStyle id="Table_Subheader_Content_detail"> + <blockAlignment value="LEFT"/> + <blockValign value="TOP"/> + <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="0,0" stop="0,-1"/> + <lineStyle kind="LINEABOVE" colorName="#cccccc" start="0,0" stop="0,0"/> + <lineStyle kind="LINEBELOW" colorName="#cccccc" start="0,-1" stop="0,-1"/> + <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="1,0" stop="1,-1"/> + <lineStyle kind="LINEABOVE" colorName="#cccccc" start="1,0" stop="1,0"/> + <lineStyle kind="LINEBELOW" colorName="#cccccc" start="1,-1" stop="1,-1"/> + <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="2,0" stop="2,-1"/> + <lineStyle kind="LINEAFTER" colorName="#cccccc" start="2,0" stop="2,-1"/> + <lineStyle kind="LINEABOVE" colorName="#cccccc" start="2,0" stop="2,0"/> + <lineStyle kind="LINEBELOW" colorName="#cccccc" start="2,-1" stop="2,-1"/> + </blockTableStyle> + <blockTableStyle id="Table_Account_detail_Title"> + <blockAlignment value="LEFT"/> + <blockValign value="TOP"/> + <lineStyle kind="LINEBELOW" colorName="#000000" start="0,0" stop="-1,0"/> + </blockTableStyle> + <blockTableStyle id="Table_Final_Total"> + <blockAlignment value="LEFT"/> + <blockValign value="TOP"/> + <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/> + <lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/> + <lineStyle kind="LINEBELOW" colorName="#000000" start="2,-1" stop="2,-1"/> + <lineStyle kind="LINEBELOW" colorName="#000000" start="3,-1" stop="3,-1"/> + </blockTableStyle> + <blockTableStyle id="Table_Journal_Line_Content"> + <blockAlignment value="LEFT"/> + <blockValign value="TOP"/> + <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,-1" stop="0,-1"/> + <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="1,-1" stop="1,-1"/> + <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="2,-1" stop="2,-1"/> + <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="3,-1" stop="3,-1"/> + </blockTableStyle> + <initialize> + <paraStyle name="all" alignment="justify"/> + </initialize> + <paraStyle name="Standard" fontName="Times-Roman"/> + <paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/> + <paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/> + <paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/> + <paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/> + <paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/> + <paraStyle name="Index" fontName="Times-Roman"/> + <paraStyle name="Heading" fontName="Helvetica" fontSize="12.0" leading="15" spaceBefore="12.0" spaceAfter="6.0"/> + <paraStyle name="Footer" fontName="Times-Roman"/> + <paraStyle name="Horizontal Line" fontName="Times-Roman" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="14.0"/> + <paraStyle name="terp_header" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/> + <paraStyle name="Heading 9" fontName="Helvetica-Bold" fontSize="75%" leading="NaN" spaceBefore="12.0" spaceAfter="6.0"/> + <paraStyle name="terp_tblheader_General" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="6.0" spaceAfter="6.0"/> + <paraStyle name="terp_tblheader_Details" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="6.0" spaceAfter="6.0"/> + <paraStyle name="terp_default_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> + <paraStyle name="terp_default_Bold_8" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> + <paraStyle name="terp_tblheader_General_Centre" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/> + <paraStyle name="terp_tblheader_General_Right" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="6.0" spaceAfter="6.0"/> + <paraStyle name="terp_tblheader_Details_Centre" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/> + <paraStyle name="terp_tblheader_Details_Right" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="6.0" spaceAfter="6.0"/> + <paraStyle name="terp_default_Right_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/> + <paraStyle name="terp_default_Centre_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> + <paraStyle name="terp_header_Right" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/> + <paraStyle name="terp_header_Centre" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/> + <paraStyle name="terp_default_address" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> + <paraStyle name="terp_default_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> + <paraStyle name="terp_default_Bold_9" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> + <paraStyle name="terp_default_Centre_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> + <paraStyle name="terp_default_Right_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/> + <paraStyle name="terp_default_2" fontName="Helvetica" fontSize="2.0" leading="3" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> + <paraStyle name="terp_default_Bold_9_Right" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/> + </stylesheet> + <images/> + <story> + <!--blockTable colWidths="180.0,180.0,180.0" style="Table_header_Content"> + <tr> + <td> + <para style="terp_header">[[ company.name ]]</para> + </td> + <td> + <para style="terp_header"> + <font color="white"> </font> + </para> + </td> + <td> + <para style="terp_header">Central Journal-[[ company.currency_id.name ]]</para> + </td> + </tr> + </blockTable--> + <para style="terp_default_8"> + <font color="white"> </font> + </para> + <para style="terp_default_8"> + <font color="white"> </font> + </para> + <para style="terp_default_8">[[ repeatIn(objects, 'o') ]]</para> + <para style="terp_default_8">[[ repeatIn(lines(data['form']['period_id'][0][2],data['form']['journal_id'][0][2]), 'line') ]]</para> + <blockTable colWidths="180.0,180.0,180.0" style="Table_Sub_Header_Content"> + <tr> + <td> + <para style="terp_tblheader_General_Centre">Journal Code</para> + </td> + <td> + <para style="terp_tblheader_General_Centre">Journal Name</para> + </td> + <td> + <para style="terp_tblheader_General_Centre">Printing Date</para> + </td> + </tr> + </blockTable> + <blockTable colWidths="180.0,180.0,180.0" style="Table_Subheader_Content_detail"> + <tr> + <td> + <para style="terp_tblheader_General_Centre">[[ line[0]['journal'].code or '' ]]</para> + </td> + <td> + <para style="terp_tblheader_General_Centre">[[ line[0]['journal'].name ]]</para> + </td> + <td> + <para style="terp_tblheader_General_Centre">[[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S') ]]</para> + </td> + </tr> + </blockTable> + <para style="terp_default_8"> + <font color="white"> </font> + </para> + <para style="terp_default_8"> + <font color="white"> </font> + </para> + <blockTable colWidths="83.0,272.0,95.0,89.0" style="Table_Account_detail_Title" repeatRows="1"> + <tr> + <td> + <para style="terp_tblheader_Details_Centre">Account Num.</para> + </td> + <td> + <para style="terp_tblheader_Details">Account Name</para> + </td> + <td> + <para style="terp_tblheader_Details_Right">Debit</para> + </td> + <td> + <para style="terp_tblheader_Details_Right">Credit</para> + </td> + </tr> + + <tr> + <td> + <blockTable colWidths="80.0,272.0,94.0,87.0" style="Table_Final_Total"> + <tr> + <td> + <para style="terp_default_Bold_9">Total:</para> + </td> + <td> + <para style="terp_default_Bold_9"> + <font color="white"> </font> + </para> + </td> + <td> + <para style="terp_default_Bold_9_Right">[[ '%.2f' % sum_debit(line[0]['period'].id, line[0]['journal'].id) ]]</para> + </td> + <td> + <para style="terp_default_Bold_9_Right">[[ '%.2f' % sum_credit(line[0]['period'].id, line[0]['journal'].id) ]]</para> + </td> + </tr> + </blockTable> + </td> + </tr> + + <tr> + <td> + <blockTable colWidths="80.0,272.0,94.0,87.0" style="Table_Journal_Line_Content"> + <para style="terp_default_8">[[repeatIn(line,'l')]]</para> + <tr> + <td> + <para style="terp_default_9">[[ l['code'] ]]</para> + </td> + <td> + <para style="terp_default_9">[[ l['name'] ]]</para> + </td> + <td> + <para style="terp_default_Right_9">[[ formatLang(l['debit']) and '%.2f' % l['debit'] or '0.00' ]]</para> + </td> + <td> + <para style="terp_default_Right_9">[[ formatLang(l['credit']) and '%.2f' % l['credit'] or '0.00' ]]</para> + </td> + </tr> + </blockTable> + </td> + </tr> + </blockTable> + <para style="terp_default_8"> + <font color="white"> </font> + </para> + </story> +</document> 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 = '''<?xml version="1.0"?> +<form string="Print Journal"> + <field name="journal_id"/> + <field name="period_id"/> +</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'}, }, } |
