From 6ff9caa04af0d0885bb1d24b90bf85c512377db6 Mon Sep 17 00:00:00 2001 From: "psi (Open ERP)" Date: Mon, 22 Nov 2010 16:40:50 +0530 Subject: [PATCH] [IMP] account: cumulative balance for journal report bzr revid: psi@tinyerp.co.in-20101122111050-jjwk79g6m5lq7g0p --- addons/account/report/account_journal.py | 20 ++++-- addons/account/report/account_journal.rml | 112 ++++++++++++++--------------- 2 files changed, 72 insertions(+), 60 deletions(-) diff --git a/addons/account/report/account_journal.py b/addons/account/report/account_journal.py index 82af01c..336a32b 100644 --- a/addons/account/report/account_journal.py +++ b/addons/account/report/account_journal.py @@ -117,10 +117,22 @@ class journal_print(report_sxw.rml_parse, common_report_header): move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted'] - - self.cr.execute('SELECT l.id FROM account_move_line l, account_move am WHERE l.move_id=am.id AND am.state IN %s AND l.period_id=%s AND l.journal_id IN %s ' + self.query_get_clause + ' ORDER BY l.'+ self.sort_selection + '',(tuple(move_state), period_id, tuple(journal_id) )) - ids = map(lambda x: x[0], self.cr.fetchall()) - return obj_mline.browse(self.cr, self.uid, ids) + self.cr.execute("SELECT l.id, l.date, l.ref, l.name, l.debit, l.credit, m.name as move_name, acc.code as account_code, rp.name as partner_name "\ + "FROM account_move_line l "\ + "LEFT JOIN account_move m ON (m.id=l.move_id) "\ + "LEFT JOIN account_account acc ON (l.account_id = acc.id) "\ + "LEFT JOIN res_partner rp ON (l.partner_id=rp.id) "\ + "WHERE m.state IN %s "\ + "AND l.period_id = %s "\ + "AND l.journal_id IN %s " + self.query_get_clause + " "\ + "ORDER BY l."+ self.sort_selection + " ", + (tuple(move_state), period_id, tuple(journal_id) )) + res = self.cr.dictfetchall() + account_sum = 0.0 + for l in res: + account_sum += l['debit'] - l['credit'] + l['progress'] = account_sum + return res def _set_get_account_currency_code(self, account_id): self.cr.execute("SELECT c.symbol AS code "\ diff --git a/addons/account/report/account_journal.rml b/addons/account/report/account_journal.rml index cb37b4e..0a20da7 100644 --- a/addons/account/report/account_journal.rml +++ b/addons/account/report/account_journal.rml @@ -176,9 +176,9 @@ - - - + + + @@ -202,44 +202,44 @@ - [[ data['model']=='account.journal.period'and 'Company' or removeParentNode('para') ]] - [[ data['model']=='ir.ui.menu' and 'Chart of Account' or removeParentNode('para') ]] + [[ data['model']=='account.journal.period'and 'Company' or removeParentNode('para') ]] + [[ data['model']=='ir.ui.menu' and 'Chart of Account' or removeParentNode('para') ]] Fiscal Year - Journal + Journal Filters By - Entries Sorted By + Entries Sorted By Target Moves - - [[ get_account(data) or '' ]] + + [[ get_account(data) or '' ]] [[ get_fiscalyear(data) or '' ]] - [[o.journal_id.name ]] - [[ get_filter(data)=='No Filter' and get_filter(data) or removeParentNode('para') ]] - [[ get_filter(data)=='Date' or removeParentNode('blockTable') ]] - - Start Date - End Date - - - [[ formatLang(get_start_date(data),date=True) ]] - [[ formatLang(get_end_date(data),date=True) ]] - - - [[ get_filter(data)=='Periods' or removeParentNode('blockTable') ]] - - Start Period - End Period - - - [[ get_start_period(data) or removeParentNode('para') ]] - [[ get_end_period(data) or removeParentNode('para') ]] - - - - [[ get_sortby(data) ]] - [[ get_target_move(data) ]] - - + [[o.journal_id.name ]] + [[ get_filter(data)=='No Filter' and get_filter(data) or removeParentNode('para') ]] + [[ get_filter(data)=='Date' or removeParentNode('blockTable') ]] + + Start Date + End Date + + + [[ formatLang(get_start_date(data),date=True) ]] + [[ formatLang(get_end_date(data),date=True) ]] + + + [[ get_filter(data)=='Periods' or removeParentNode('blockTable') ]] + + Start Period + End Period + + + [[ get_start_period(data) or removeParentNode('para') ]] + [[ get_end_period(data) or removeParentNode('para') ]] + + + + [[ get_sortby(data) ]] + [[ get_target_move(data) ]] + + @@ -269,14 +269,14 @@ [[lines(o.period_id.id, o.journal_id.id) or removeParentNode('story') ]] - [[ repeatIn(lines(o.period_id.id, o.journal_id.id), 'line') ]][[ formatLang(line.date,date=True) ]] - [[ line.ref ]] - [[ line.account_id.code ]] - [[ line.partner_id and line.partner_id.name ]] - [[ line.move_id.name ]] - [[ line.name ]] - [[ formatLang(line.debit) ]] - [[ formatLang(line.credit) ]] - [[ formatLang(line.credit - line.debit) ]] [[ company.currency_id.symbol ]] + [[ repeatIn(lines(o.period_id.id, o.journal_id.id), 'line') ]][[ formatLang(line['date'],date=True) ]] + [[ line['ref'] or '' ]] + [[ line['account_code'] or '' ]] + [[ line['partner_name'] or '' ]] + [[ line['move_name'] or '' ]] - [[ line['name'] or '' ]] + [[ formatLang(line['debit']) ]] + [[ formatLang(line['credit']) ]] + [[ formatLang(line['progress']) ]] [[ company.currency_id.symbol ]] @@ -290,8 +290,8 @@ Move/Entry label Debit Credit - Balance - Currency + Balance + Currency [[o.period_id.name ]] @@ -301,19 +301,19 @@ [[ formatLang(sum_debit(o.period_id.id, o.journal_id.id)) ]] [[ formatLang(sum_credit(o.period_id.id, o.journal_id.id)) ]] - [[ formatLang((sum_debit(o.period_id.id, o.journal_id.id) - sum_credit(o.period_id.id, o.journal_id.id))) ]] [[ company.currency_id.symbol ]] + [[ formatLang((sum_debit(o.period_id.id, o.journal_id.id) - sum_credit(o.period_id.id, o.journal_id.id))) ]] [[ company.currency_id.symbol ]] [[lines(o.period_id.id, o.journal_id.id) or removeParentNode('story') ]] - [[ repeatIn(lines(o.period_id.id, o.journal_id.id), 'line') ]][[ formatLang(line.date,date=True) ]] - [[ line.ref ]] - [[ line.account_id.code ]] - [[ line.partner_id and line.partner_id.name ]] - [[ line.move_id.name ]] - [[ line.name ]] - [[ formatLang(line.debit) ]] - [[ formatLang(line.credit) ]] - [[ formatLang(line.credit - line.debit) ]] [[ company.currency_id.symbol ]] - [[ line.currency_id and formatLang(line.amount_currency) or '' ]] [[ line.currency_id.symbol or '']] + [[ repeatIn(lines(o.period_id.id, o.journal_id.id), 'line') ]][[ formatLang(line['date'],date=True) ]] + [[ line['ref'] or '' ]] + [[ line['account_code'] or '' ]] + [[ line['partner_name'] or '' ]] + [[ line['move_name'] or '' ]] - [[ line['name'] or '' ]] + [[ formatLang(line['debit']) ]] + [[ formatLang(line['credit']) ]] + [[ formatLang(line['progress']) ]] [[ company.currency_id.symbol ]] + [[ line.currency_id and formatLang(line.amount_currency) or '' ]] [[ line.currency_id.symbol or '']] -- 1.7.10.4