diff --git a/addons/account/report/account_report_common.py b/addons/account/report/account_report_common.py index 69b5668bdbe..57a97f8ab4e 100644 --- a/addons/account/report/account_report_common.py +++ b/addons/account/report/account_report_common.py @@ -19,7 +19,7 @@ ############################################################################## import time -import pooler + from report import report_sxw from common_report_header import common_report_header from tools.translate import _ @@ -53,9 +53,8 @@ class report_account_common(report_sxw.rml_parse, common_report_header): def _get_report_details(self, data): cr, uid = self.cr, self.uid - db_pool = pooler.get_pool(self.cr.dbname) - report_obj = db_pool.get('account.report') + report_obj = self.pool.get('account.report') datas = [] balance = 0.0 name = data['form'].get('account_report_id') and data['form']['account_report_id'][1] or '' @@ -64,27 +63,31 @@ class report_account_common(report_sxw.rml_parse, common_report_header): if report_id: child_ids = report_obj.search(cr, uid, [('parent_id','=',report_id)]) child_ids.append(datas[0]['id']) - for chld in report_obj.browse(cr, uid, child_ids): - if chld.type == 'accounts': - for a in chld.account_ids: + for child in report_obj.browse(cr, uid, child_ids): + if child.type == 'accounts': + for a in child.account_ids: balance += a.balance - if chld.type == 'account_report': - pass # TDDO: it's the balance of the linked account.report (so it means it's only a way to reuse figures coming from another report) - if chld.type == 'sum': - pass # TDDO: it's the sum of balance of the children of this account.report (if there isn't, then it's 0.0) - if chld.id == datas[0]['id']: - datas[0].update({'name': chld.name, 'balance': balance}) + # it's the balance of the linked account.report (so it means it's only a way to reuse figures coming from another report) + if child.type == 'account_report' and child.account_report_id: + for a in child.account_report_id.account_ids: + balance +=a.balance + #it's the sum of balance of the children of this account.report (if there isn't, then it's 0.0) + if child.type == 'sum': + for child in report_obj.browse(cr, uid, child_ids): + for a in child.account_ids: + balance += a.balance + if child.id == datas[0]['id']: + datas[0].update({'name': child.name, 'balance': balance}) else: - datas.append({'id': chld.id, 'name': chld.name, 'balance': balance}) + datas.append({'id': child.id, 'name': child.name, 'balance': balance}) return datas - def get_account_details(self, acc_id): + def get_account_details(self, acc_id, data): cr, uid = self.cr, self.uid - db_pool = pooler.get_pool(self.cr.dbname) - report_obj = db_pool.get('account.report') + report_obj = self.pool.get('account.report') accounts = [] - if acc_id: + if acc_id and data['form'].get('display_details_per_account', False): for rpt in report_obj.browse(cr, uid, [acc_id]): for acc in rpt.account_ids: accounts.append({'code': acc.code, 'name': acc.name, 'bal': acc.balance}) diff --git a/addons/account/report/account_report_common.rml b/addons/account/report/account_report_common.rml index 9918ad0ee18..602f072f47d 100644 --- a/addons/account/report/account_report_common.rml +++ b/addons/account/report/account_report_common.rml @@ -59,6 +59,7 @@ + @@ -68,133 +69,74 @@ - + - - Chart of Account - - - Fiscal Year - - - Filters By [[ get_filter(data)!='No Filter' and get_filter(data) ]] - + Chart of Account + Fiscal Year + Filter By [[ get_filter(data)!='No Filter' and '' or removeParentNode('font') ]] - - - [[ get_account(data) or '' ]] + + [[ get_account(data) or removeParentNode('para') ]] + [[ get_fiscalyear(data) or '' ]] + [[ 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_fiscalyear(data) or '' ]] - - - - - - [[ get_filter(data)=='Date' or removeParentNode('blockTable') ]] - Start Date - - - End Date - - - - - [[ get_start_date(data) ]] - - - [[ get_end_date(data) ]] - - - - - - - [[ 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') ]] - - - - - - - - + - - - + + + [[ repeatIn(get_report_details(data),'r') ]] - + - - Report Name - - - Report Balance - + Report Name + Report Balance - - [[ r['name'] ]] - - - [[ r['balance'] ]] - + [[ r['name'] ]] + [[ r['balance'] ]] - + - - Account Details - + Account Details - + - - Code - - - Name - - - Balance - + Code + Name + Balance - - - [[ repeatIn(get_account_details(r['id']), 'a') ]] [[ a['code'] ]] - - - - - [[ a['name'] ]] - - - - - [[ a['bal'] ]] - - + [[ repeatIn(get_account_details(r['id'], data), 'a') ]] [[ a['code'] ]] + [[ a['name'] ]] + [[ a['bal'] ]] diff --git a/addons/account/wizard/account_report.py b/addons/account/wizard/account_report.py index 784c1e03a7b..064c9bb723e 100644 --- a/addons/account/wizard/account_report.py +++ b/addons/account/wizard/account_report.py @@ -32,10 +32,14 @@ class accounting_report(osv.osv_memory): 'account_report_id': fields.many2one('account.report', 'Account Reports', required=True), } + _defaults={ + 'enable_comparison': False, + 'display_details_per_account': False, + } def _print_report(self, cr, uid, ids, data, context=None): if context is None: context = {} - data['form'].update(self.read(cr, uid, ids, ['account_report_id'], context=context)[0]) + data['form'].update(self.read(cr, uid, ids, ['account_report_id', 'enable_comparison', 'display_details_per_account'], context=context)[0]) return { 'type': 'ir.actions.report.xml', 'report_name': 'account.common',