From 704a0a5c27accf6a554eec849b0bde255ae05787 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Wed, 10 Sep 2008 15:26:51 +0530 Subject: [PATCH] Modify general ledger report: - add boolean field on account defincation (display history)..it its true it will display lines otherwise only balance of that account bzr revid: mra@tinyerp.com-20080910095651-9b7eor3or39u7ma7 --- addons/account/account.py | 2 + addons/account/account_view.xml | 1 + addons/account/report/general_ledger.py | 11 +- addons/account/report/general_ledger.rml | 193 +++++++++++------------ 4 files changed, 105 insertions(+), 102 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 1ced6bd88e8..652e74b9acd 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -244,6 +244,7 @@ class account_account(osv.osv): 'parent_left': fields.integer('Parent Left', select=1), 'parent_right': fields.integer('Parent Right', select=1), + 'check_history': fields.boolean('Display History', help="Check this box if you want to print all entries otherwise it will print balance of this account") } def _default_company(self, cr, uid, context={}): @@ -257,6 +258,7 @@ class account_account(osv.osv): 'reconcile': lambda *a: False, 'company_id': _default_company, 'active': lambda *a: True, + 'check_history': lambda *a: True, } def _check_recursion(self, cr, uid, ids): diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 7a44e823b79..b422430ae5a 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -124,6 +124,7 @@ + diff --git a/addons/account/report/general_ledger.py b/addons/account/report/general_ledger.py index 90a787ab245..3317c81bd16 100644 --- a/addons/account/report/general_ledger.py +++ b/addons/account/report/general_ledger.py @@ -42,6 +42,7 @@ class general_ledger(report_sxw.rml_parse): 'sum_credit_account': self._sum_credit_account, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, + 'check_lines': self.check_lines, }) self.context = context @@ -101,8 +102,17 @@ class general_ledger(report_sxw.rml_parse): return ret_data + def check_lines(self, account, form): + result = self.lines(account, form, history=True) + res = [{'code':account.code,'name':account.name}] + if not result: + res = [] + return res def lines(self, account, form): + self.ids +=[account.id] + if not account.check_history and not history: + return [] ctx = self.context.copy() ctx['fiscalyear'] = form['fiscalyear'] @@ -120,7 +130,6 @@ class general_ledger(report_sxw.rml_parse): for l in res: sum += l['debit'] - l ['credit'] l['progress'] = sum - self.ids +=[account.id] return res def _sum_debit_account(self, account, form): diff --git a/addons/account/report/general_ledger.rml b/addons/account/report/general_ledger.rml index 44ec036da65..4a02988bc18 100644 --- a/addons/account/report/general_ledger.rml +++ b/addons/account/report/general_ledger.rml @@ -13,63 +13,30 @@ - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - + - + - + - - - - - - - - - - - - - + @@ -87,9 +54,16 @@ - - - + + + + + + + + + + @@ -97,8 +71,8 @@ + - @@ -137,7 +111,7 @@ - + Date @@ -165,59 +139,76 @@ -
- [[ repeatIn(objects, 'o') ]] - [[ o.code ]] [[ o.name ]] - - - - [[ repeatIn(lines(o, data['form']), 'line') ]][[ line['date'] ]] - - - [[ line['code'] ]] - - - [[ line['ref'] ]] - - - [[ line['name'] ]] - - - [[ formatLang(line['debit']) ]] - - - [[ formatLang(line['credit']) ]] - - - [[ formatLang(line['progress']) ]] - - - - - - - TOTAL ([[ o.code ]]): - - - [[ formatLang(sum_debit_account(o, data['form'])) ]] - - - [[ formatLang(sum_credit_account(o, data['form'])) ]] - - - - - - - - - - - -
- - - + + + + [[ repeatIn(objects, 'o') ]]  + [[ repeatIn(check_lines(o,data['form']), 'acc') ]] + + [[ acc and acc['code'] or removeParentNode('para') ]] [[ acc and acc['name'] or removeParentNode('para') ]] + + + + + [[ repeatIn(lines(o, data['form']), 'line') ]][[ line['date'] ]] + + + [[ line['code'] ]] + + + [[ line['ref'] ]] + + + [[ line['name'] ]] + + + [[ formatLang(line['debit']) ]] + + + [[ formatLang(line['credit']) ]] + + + [[ formatLang(line['progress']) ]] + + + + + + + + + + + + + + + + + + + + + + + TOTAL ([[ acc and acc['code'] or removeParentNode('para') ]]): + + + [[ formatLang(sum_debit_account(o, data['form'])) ]] + + + [[ formatLang(sum_credit_account(o, data['form'])) ]] + + + + + + + + + + +