From 27a0a2c059e3cf5cbca02700b9f4ffb8c30150d0 Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Thu, 11 Aug 2011 16:38:47 +0530 Subject: [PATCH 01/38] [ADD] account: Added new object account.report for printing reports. bzr revid: uco@tinyerp.com-20110811110847-telg63rtz0bshdry --- addons/account/__openerp__.py | 1 + addons/account/wizard/__init__.py | 1 + addons/account/wizard/account_report.py | 45 +++++++++++++++ addons/account/wizard/account_report_view.xml | 56 +++++++++++++++++++ 4 files changed, 103 insertions(+) create mode 100644 addons/account/wizard/account_report.py create mode 100644 addons/account/wizard/account_report_view.xml diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index 23846183ddf..93270889657 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -98,6 +98,7 @@ module named account_voucher. 'wizard/account_reconcile_view.xml', 'wizard/account_reconcile_partner_process_view.xml', 'wizard/account_automatic_reconcile_view.xml', + 'wizard/account_report_view.xml', 'project/wizard/project_account_analytic_line_view.xml', 'account_end_fy.xml', 'account_invoice_view.xml', diff --git a/addons/account/wizard/__init__.py b/addons/account/wizard/__init__.py index caed6fc3977..f6090539b73 100644 --- a/addons/account/wizard/__init__.py +++ b/addons/account/wizard/__init__.py @@ -47,6 +47,7 @@ import account_open_closed_fiscalyear import account_invoice_state import account_chart import account_tax_chart +import account_report #TODO: remove this file no moe used # also remove related view fiel diff --git a/addons/account/wizard/account_report.py b/addons/account/wizard/account_report.py new file mode 100644 index 00000000000..3cd3b06be44 --- /dev/null +++ b/addons/account/wizard/account_report.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from osv import fields, osv + +class account_report(osv.osv_memory): + _name = "account.report" + _inherit = "account.common.report" + _description = "Account Report" + + _columns = { + 'parent_id': fields.many2one('account.report', 'Report'), + 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of invoice tax."), + 'type': fields.selection([ + ('sum','Sum'), + ('accounts','Accounts'), + ('account_report','Account Report'), + ],'Type'), + 'account_ids': fields.many2many('account.account', 'account_account_report', 'report_line_id', 'account_id', 'Accounts'), + 'note': fields.text('Notes'), + 'account_report_id': fields.many2one('account.report', 'Account Reports'), + 'enable_comparison': fields.boolean('Enable Comparison'), + } + +account_report() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_report_view.xml b/addons/account/wizard/account_report_view.xml new file mode 100644 index 00000000000..0b326626ee2 --- /dev/null +++ b/addons/account/wizard/account_report_view.xml @@ -0,0 +1,56 @@ + + + + + + Account Report + account.report + form + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Mail Report + account.report + ir.actions.act_window + form + form + + new + + + + + + From d4ee49e658a90657da2dc848c40e2dd31d5cd71d Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Fri, 12 Aug 2011 16:53:21 +0530 Subject: [PATCH 02/38] [IMP] account: Improved report. bzr revid: uco@tinyerp.com-20110812112321-3q1vfylgojz0s91h --- addons/account/account.py | 28 ++- addons/account/account_menuitem.xml | 1 + addons/account/account_view.xml | 49 +++++ addons/account/report/__init__.py | 1 + .../account/report/account_report_common.py | 83 ++++++++ .../account/report/account_report_common.rml | 187 ++++++++++++++++++ addons/account/wizard/account_report.py | 28 +-- addons/account/wizard/account_report_view.xml | 24 +-- 8 files changed, 371 insertions(+), 30 deletions(-) create mode 100644 addons/account/report/account_report_common.py create mode 100644 addons/account/report/account_report_common.rml diff --git a/addons/account/account.py b/addons/account/account.py index 72208314ed9..ec72237c897 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1331,7 +1331,7 @@ class account_move(osv.osv): def _centralise(self, cr, uid, move, mode, context=None): assert mode in ('debit', 'credit'), 'Invalid Mode' #to prevent sql injection - currency_obj = self.pool.get('res.currency') + currency_obj = self.pool.get('res.currency') if context is None: context = {} @@ -1593,7 +1593,7 @@ class account_tax_code(osv.osv): (parent_ids,) + where_params) res=dict(cr.fetchall()) obj_precision = self.pool.get('decimal.precision') - res2 = {} + res2 = {} for record in self.browse(cr, uid, ids, context=context): def _rec_get(record): amount = res.get(record.id, 0.0) @@ -2607,6 +2607,30 @@ class account_fiscal_position_account_template(osv.osv): account_fiscal_position_account_template() +class account_report(osv.osv): + _name = "account.report" + _description = "Account Report" + + _columns = { + 'name': fields.char('Report Name', size=64, required=True), + 'parent_id': fields.many2one('account.report', 'Parent Report'), + 'sequence': fields.integer('Sequence'), + 'type': fields.selection([ + ('sum','Sum'), + ('accounts','Accounts'), + ('account_report','Account Report'), + ],'Type'), + 'account_ids': fields.many2many('account.account', 'account_account_report', 'report_line_id', 'account_id', 'Accounts'), + 'note': fields.text('Notes'), + 'account_report_id': fields.many2one('account.report', 'Account Report'), + } + + _defaults = { + 'type': 'sum', + } + +account_report() + # Multi charts of Accounts wizard class wizard_multi_charts_accounts(osv.osv_memory): diff --git a/addons/account/account_menuitem.xml b/addons/account/account_menuitem.xml index 062e1f6382b..48fe424e7fb 100644 --- a/addons/account/account_menuitem.xml +++ b/addons/account/account_menuitem.xml @@ -30,6 +30,7 @@ + + + + + account.report.form + account.report + form + +
+ + + + + + + + + + + +
+ + + account.report.tree + account.report + tree + + + + + + + + + + + + + Account Reports + ir.actions.act_window + account.report + form + tree,form + + + + + diff --git a/addons/account/report/__init__.py b/addons/account/report/__init__.py index 7c09027f3ca..86c13a85582 100644 --- a/addons/account/report/__init__.py +++ b/addons/account/report/__init__.py @@ -42,6 +42,7 @@ import account_analytic_entries_report import account_balance_sheet import account_profit_loss import account_treasury_report +import account_report_common # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/account_report_common.py b/addons/account/report/account_report_common.py new file mode 100644 index 00000000000..a2dbf62e7fa --- /dev/null +++ b/addons/account/report/account_report_common.py @@ -0,0 +1,83 @@ +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import time +import pooler +from report import report_sxw +from common_report_header import common_report_header +from tools.translate import _ + +class report_account_common(report_sxw.rml_parse, common_report_header): + + def __init__(self, cr, uid, name, context=None): + super(report_account_common, self).__init__(cr, uid, name, context=context) + self.localcontext.update( { + 'time': time, + 'get_report_name': self._get_report_name, + 'get_fiscalyear': self._get_fiscalyear, + 'get_account': self._get_account, + 'get_start_period': self.get_start_period, + 'get_end_period': self.get_end_period, + 'get_sortby': self._get_sortby, + 'get_filter': self._get_filter, + 'get_start_date':self._get_start_date, + 'get_end_date':self._get_end_date, + 'get_company':self._get_company, + 'get_account_details': self.get_account_details, + }) + self.context = context + + def set_context(self, objects, data, ids, report_type=None): + new_ids = ids + if (data['model'] == 'ir.ui.menu'): + new_ids = 'chart_account_id' in data['form'] and [data['form']['chart_account_id']] or [] + objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids) + return super(report_account_common, self).set_context(objects, data, new_ids, report_type=report_type) + + def _get_report_name(self, data): + cr, uid = self.cr, self.uid + db_pool = pooler.get_pool(self.cr.dbname) + + report_obj = db_pool.get('account.report') + children = [] + name = data['form'].get('account_report_id') and data['form']['account_report_id'][1] or '' + report_id = data['form'].get('account_report_id') and data['form']['account_report_id'][0] or False + children.append({'id': report_id, 'name': name}) + if report_id: + child_ids = report_obj.search(cr, uid, [('parent_id','=',report_id)]) + for chld in report_obj.browse(cr, uid, child_ids): + children.append({'id': chld.id, 'name': chld.name}) + return children + + def get_account_details(self, acc_id): + cr, uid = self.cr, self.uid + db_pool = pooler.get_pool(self.cr.dbname) + + report_obj = db_pool.get('account.report') + accounts = [] + if acc_id: + 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}) + return accounts + +report_sxw.report_sxw('report.account.common', 'account.account', + 'addons/account/report/account_report_common.rml', parser=report_account_common, header='internal') + diff --git a/addons/account/report/account_report_common.rml b/addons/account/report/account_report_common.rml new file mode 100644 index 00000000000..c0864862fbf --- /dev/null +++ b/addons/account/report/account_report_common.rml @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Chart of Account + + + Fiscal Year + + + Filters By [[ get_filter(data)!='No Filter' and get_filter(data) ]] + + + + + [[ get_account(data) or '' ]] + + + [[ 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_name(data),'r') ]] + + + [[ r['name'] ]] + + + + Account Details + + + + + + + Code + + + Name + + + Balance + + + + + + [[ repeatIn(get_account_details(r['id']), 'a') ]] [[ a['code'] ]] + + + + + [[ a['name'] ]] + + + + + [[ a['bal'] ]] + + + + + + + + + + + + diff --git a/addons/account/wizard/account_report.py b/addons/account/wizard/account_report.py index 3cd3b06be44..784c1e03a7b 100644 --- a/addons/account/wizard/account_report.py +++ b/addons/account/wizard/account_report.py @@ -21,25 +21,27 @@ from osv import fields, osv -class account_report(osv.osv_memory): - _name = "account.report" +class accounting_report(osv.osv_memory): + _name = "accounting.report" _inherit = "account.common.report" _description = "Account Report" _columns = { - 'parent_id': fields.many2one('account.report', 'Report'), - 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of invoice tax."), - 'type': fields.selection([ - ('sum','Sum'), - ('accounts','Accounts'), - ('account_report','Account Report'), - ],'Type'), - 'account_ids': fields.many2many('account.account', 'account_account_report', 'report_line_id', 'account_id', 'Accounts'), - 'note': fields.text('Notes'), - 'account_report_id': fields.many2one('account.report', 'Account Reports'), 'enable_comparison': fields.boolean('Enable Comparison'), + 'display_details_per_account': fields.boolean('Display Details per Account'), + 'account_report_id': fields.many2one('account.report', 'Account Reports', required=True), } -account_report() + 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]) + return { + 'type': 'ir.actions.report.xml', + 'report_name': 'account.common', + 'datas': data, + } + +accounting_report() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_report_view.xml b/addons/account/wizard/account_report_view.xml index 0b326626ee2..119b1d7f1bd 100644 --- a/addons/account/wizard/account_report_view.xml +++ b/addons/account/wizard/account_report_view.xml @@ -2,19 +2,16 @@ - + Account Report - account.report + accounting.report form - - - - - - + + + @@ -28,25 +25,22 @@ - - - - Mail Report - account.report + Report + accounting.report ir.actions.act_window form form - + new Date: Fri, 12 Aug 2011 17:52:34 +0530 Subject: [PATCH 03/38] [IMP] account: Improved report. bzr revid: uco@tinyerp.com-20110812122234-rkh36ya1zzmonpnt --- .../account/report/account_report_common.py | 28 +++++++++++++++---- .../account/report/account_report_common.rml | 24 ++++++++++++++-- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/addons/account/report/account_report_common.py b/addons/account/report/account_report_common.py index a2dbf62e7fa..69b5668bdbe 100644 --- a/addons/account/report/account_report_common.py +++ b/addons/account/report/account_report_common.py @@ -30,7 +30,7 @@ class report_account_common(report_sxw.rml_parse, common_report_header): super(report_account_common, self).__init__(cr, uid, name, context=context) self.localcontext.update( { 'time': time, - 'get_report_name': self._get_report_name, + 'get_report_details': self._get_report_details, 'get_fiscalyear': self._get_fiscalyear, 'get_account': self._get_account, 'get_start_period': self.get_start_period, @@ -51,20 +51,32 @@ class report_account_common(report_sxw.rml_parse, common_report_header): objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids) return super(report_account_common, self).set_context(objects, data, new_ids, report_type=report_type) - def _get_report_name(self, data): + 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') - children = [] + datas = [] + balance = 0.0 name = data['form'].get('account_report_id') and data['form']['account_report_id'][1] or '' report_id = data['form'].get('account_report_id') and data['form']['account_report_id'][0] or False - children.append({'id': report_id, 'name': name}) + datas.append({'id': report_id}) 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): - children.append({'id': chld.id, 'name': chld.name}) - return children + if chld.type == 'accounts': + for a in chld.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}) + else: + datas.append({'id': chld.id, 'name': chld.name, 'balance': balance}) + return datas def get_account_details(self, acc_id): cr, uid = self.cr, self.uid @@ -78,6 +90,10 @@ class report_account_common(report_sxw.rml_parse, common_report_header): accounts.append({'code': acc.code, 'name': acc.name, 'bal': acc.balance}) return accounts + def get_report_balance(self): + balance = 0.0 + return balance + report_sxw.report_sxw('report.account.common', 'account.account', 'addons/account/report/account_report_common.rml', parser=report_account_common, header='internal') diff --git a/addons/account/report/account_report_common.rml b/addons/account/report/account_report_common.rml index c0864862fbf..9918ad0ee18 100644 --- a/addons/account/report/account_report_common.rml +++ b/addons/account/report/account_report_common.rml @@ -136,10 +136,30 @@ - [[ repeatIn(get_report_name(data),'r') ]] + [[ repeatIn(get_report_details(data),'r') ]] - [[ r['name'] ]] + + + + Report Name + + + Report Balance + + + + + [[ r['name'] ]] + + + [[ r['balance'] ]] + + + + + + From 56ca812f04f110a84c67d7ae643914bccf1c71ff Mon Sep 17 00:00:00 2001 From: "Purnendu Singh (OpenERP)" Date: Wed, 17 Aug 2011 17:32:19 +0530 Subject: [PATCH 04/38] [IMP] account: Improve the code so it will consider the check box display_details_per_account, improve rml, and some logic bzr revid: psi@tinyerp.com-20110817120219-39eg41ofgeyniyk1 --- .../account/report/account_report_common.py | 37 +++-- .../account/report/account_report_common.rml | 152 ++++++------------ addons/account/wizard/account_report.py | 6 +- 3 files changed, 72 insertions(+), 123 deletions(-) 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', From 2854c3091ed8c4a507a29b5768951213ced8c6b7 Mon Sep 17 00:00:00 2001 From: "Mustufa Rangwala (OpenERP)" Date: Thu, 18 Aug 2011 11:10:26 +0530 Subject: [PATCH 05/38] [IMP] Code clean bzr revid: mra@tinyerp.com-20110818054026-1c8295185zn9vmp4 --- addons/account/account.py | 4 ++-- addons/account/report/account_report_common.py | 2 -- addons/account/wizard/account_report.py | 9 +-------- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index f58f478b5fd..ba8cdbcd9a2 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -2612,8 +2612,8 @@ class account_report(osv.osv): _description = "Account Report" _columns = { - 'name': fields.char('Report Name', size=64, required=True), - 'parent_id': fields.many2one('account.report', 'Parent Report'), + 'name': fields.char('Report Name', size=32, required=True), + 'parent_id': fields.many2one('account.report', 'Parent'), 'sequence': fields.integer('Sequence'), 'type': fields.selection([ ('sum','Sum'), diff --git a/addons/account/report/account_report_common.py b/addons/account/report/account_report_common.py index 57a97f8ab4e..c8b899e5311 100644 --- a/addons/account/report/account_report_common.py +++ b/addons/account/report/account_report_common.py @@ -53,7 +53,6 @@ class report_account_common(report_sxw.rml_parse, common_report_header): def _get_report_details(self, data): cr, uid = self.cr, self.uid - report_obj = self.pool.get('account.report') datas = [] balance = 0.0 @@ -84,7 +83,6 @@ class report_account_common(report_sxw.rml_parse, common_report_header): def get_account_details(self, acc_id, data): cr, uid = self.cr, self.uid - report_obj = self.pool.get('account.report') accounts = [] if acc_id and data['form'].get('display_details_per_account', False): diff --git a/addons/account/wizard/account_report.py b/addons/account/wizard/account_report.py index 064c9bb723e..1174fb04bfc 100644 --- a/addons/account/wizard/account_report.py +++ b/addons/account/wizard/account_report.py @@ -31,14 +31,7 @@ class accounting_report(osv.osv_memory): 'display_details_per_account': fields.boolean('Display Details per Account'), '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', 'enable_comparison', 'display_details_per_account'], context=context)[0]) return { 'type': 'ir.actions.report.xml', @@ -48,4 +41,4 @@ class accounting_report(osv.osv_memory): accounting_report() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file From e111108320459ca80a303126659ae13826d8e2a2 Mon Sep 17 00:00:00 2001 From: "Purnendu Singh (OpenERP)" Date: Fri, 19 Aug 2011 11:10:14 +0530 Subject: [PATCH 06/38] [IMP] accunt : small improvments like renaming variable bzr revid: psi@tinyerp.com-20110819054014-bh4cut8jd3d3nwv0 --- addons/account/report/account_report_common.rml | 10 +++++----- addons/account/wizard/account_report.py | 6 +++--- addons/account/wizard/account_report_view.xml | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/addons/account/report/account_report_common.rml b/addons/account/report/account_report_common.rml index 602f072f47d..130d903a62a 100644 --- a/addons/account/report/account_report_common.rml +++ b/addons/account/report/account_report_common.rml @@ -13,22 +13,22 @@ - + - + xtly - + - + @@ -37,7 +37,7 @@ - + diff --git a/addons/account/wizard/account_report.py b/addons/account/wizard/account_report.py index 064c9bb723e..1cc4e2d32c0 100644 --- a/addons/account/wizard/account_report.py +++ b/addons/account/wizard/account_report.py @@ -27,8 +27,8 @@ class accounting_report(osv.osv_memory): _description = "Account Report" _columns = { - 'enable_comparison': fields.boolean('Enable Comparison'), - 'display_details_per_account': fields.boolean('Display Details per Account'), + 'comparison': fields.boolean('Enable Comparison'), + 'account_details': fields.boolean('Details by Account'), 'account_report_id': fields.many2one('account.report', 'Account Reports', required=True), } @@ -39,7 +39,7 @@ class accounting_report(osv.osv_memory): 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', 'enable_comparison', 'display_details_per_account'], context=context)[0]) + data['form'].update(self.read(cr, uid, ids, ['account_report_id', 'comparison', 'account_details'], context=context)[0]) return { 'type': 'ir.actions.report.xml', 'report_name': 'account.common', diff --git a/addons/account/wizard/account_report_view.xml b/addons/account/wizard/account_report_view.xml index 119b1d7f1bd..6c436f97057 100644 --- a/addons/account/wizard/account_report_view.xml +++ b/addons/account/wizard/account_report_view.xml @@ -10,11 +10,11 @@ - - + + - + From 98cb234bf6e94dbafbabed6e782d7950b7d5dd93 Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Fri, 19 Aug 2011 17:42:02 +0530 Subject: [PATCH 07/38] [IMP] account: Small improvements in formatting and improved some code. bzr revid: uco@tinyerp.com-20110819121202-i827lpb1yq8y5hyh --- .../account/report/account_report_common.py | 29 ++++++++++--------- .../account/report/account_report_common.rml | 16 +++++----- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/addons/account/report/account_report_common.py b/addons/account/report/account_report_common.py index c8b899e5311..21a1eb5f6e3 100644 --- a/addons/account/report/account_report_common.py +++ b/addons/account/report/account_report_common.py @@ -63,18 +63,7 @@ class report_account_common(report_sxw.rml_parse, common_report_header): child_ids = report_obj.search(cr, uid, [('parent_id','=',report_id)]) child_ids.append(datas[0]['id']) for child in report_obj.browse(cr, uid, child_ids): - if child.type == 'accounts': - for a in child.account_ids: - balance += a.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 + balance = self.get_report_balance(child) if child.id == datas[0]['id']: datas[0].update({'name': child.name, 'balance': balance}) else: @@ -85,14 +74,26 @@ class report_account_common(report_sxw.rml_parse, common_report_header): cr, uid = self.cr, self.uid report_obj = self.pool.get('account.report') accounts = [] - if acc_id and data['form'].get('display_details_per_account', False): + if acc_id and data['form'].get('account_details', 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}) return accounts - def get_report_balance(self): + def get_report_balance(self, child): balance = 0.0 + if child.type == 'accounts': + for a in child.account_ids: + balance += a.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 return balance report_sxw.report_sxw('report.account.common', 'account.account', diff --git a/addons/account/report/account_report_common.rml b/addons/account/report/account_report_common.rml index 130d903a62a..44edd762bdb 100644 --- a/addons/account/report/account_report_common.rml +++ b/addons/account/report/account_report_common.rml @@ -105,29 +105,31 @@ - + [[ repeatIn(get_report_details(data),'r') ]] - + Report Name Report Balance [[ r['name'] ]] - [[ r['balance'] ]] + [[ formatLang(r['balance']) ]] - + - Account Details + + Account Details + - + Code Name @@ -136,7 +138,7 @@ [[ repeatIn(get_account_details(r['id'], data), 'a') ]] [[ a['code'] ]] [[ a['name'] ]] - [[ a['bal'] ]] + [[ formatLang(a['bal']) ]] From 5989085e5ad751454a769236c7b307fe2d1d223f Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Tue, 23 Aug 2011 15:05:25 +0530 Subject: [PATCH 08/38] [IMP] account: Improved account report. bzr revid: uco@tinyerp.com-20110823093525-me84x0jpndcmc5po --- .../account/report/account_report_common.py | 30 +- .../account/report/account_report_common.rml | 349 ++++++++++++------ addons/account/wizard/account_report_view.xml | 2 +- 3 files changed, 257 insertions(+), 124 deletions(-) diff --git a/addons/account/report/account_report_common.py b/addons/account/report/account_report_common.py index 21a1eb5f6e3..05a4049ee30 100644 --- a/addons/account/report/account_report_common.py +++ b/addons/account/report/account_report_common.py @@ -35,11 +35,9 @@ class report_account_common(report_sxw.rml_parse, common_report_header): 'get_account': self._get_account, 'get_start_period': self.get_start_period, 'get_end_period': self.get_end_period, - 'get_sortby': self._get_sortby, 'get_filter': self._get_filter, 'get_start_date':self._get_start_date, 'get_end_date':self._get_end_date, - 'get_company':self._get_company, 'get_account_details': self.get_account_details, }) self.context = context @@ -59,11 +57,12 @@ class report_account_common(report_sxw.rml_parse, common_report_header): name = data['form'].get('account_report_id') and data['form']['account_report_id'][1] or '' report_id = data['form'].get('account_report_id') and data['form']['account_report_id'][0] or False datas.append({'id': report_id}) + ctx = self.context.copy() if report_id: child_ids = report_obj.search(cr, uid, [('parent_id','=',report_id)]) child_ids.append(datas[0]['id']) - for child in report_obj.browse(cr, uid, child_ids): - balance = self.get_report_balance(child) + for child in report_obj.browse(cr, uid, child_ids, context=ctx): + balance = self.get_report_balance(child, child_ids, ctx) if child.id == datas[0]['id']: datas[0].update({'name': child.name, 'balance': balance}) else: @@ -74,14 +73,27 @@ class report_account_common(report_sxw.rml_parse, common_report_header): cr, uid = self.cr, self.uid report_obj = self.pool.get('account.report') accounts = [] + + ctx = self.context.copy() + ctx['fiscalyear'] = data['form'].get('fiscalyear_id', False) + + if data['form']['filter'] == 'filter_period': + ctx['period_from'] = data['form'].get('period_from', False) + ctx['period_to'] = data['form'].get('period_to', False) + elif data['form']['filter'] == 'filter_date': + ctx['date_from'] = data['form'].get('date_from', False) + ctx['date_to'] = data['form'].get('date_to', False) + if acc_id and data['form'].get('account_details', 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}) + for rpt in report_obj.browse(cr, uid, [acc_id], context=ctx): + accounts = [acc for acc in rpt.account_ids if acc.level != 0] return accounts - def get_report_balance(self, child): + def get_report_balance(self, child, child_ids, context=None): + cr, uid = self.cr, self.uid + report_obj = self.pool.get('account.report') balance = 0.0 + # it's the sum of balance of the linked accounts if child.type == 'accounts': for a in child.account_ids: balance += a.balance @@ -91,7 +103,7 @@ class report_account_common(report_sxw.rml_parse, common_report_header): 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 child in report_obj.browse(cr, uid, child_ids, context=context): for a in child.account_ids: balance += a.balance return balance diff --git a/addons/account/report/account_report_common.rml b/addons/account/report/account_report_common.rml index 44edd762bdb..adc751f9cab 100644 --- a/addons/account/report/account_report_common.rml +++ b/addons/account/report/account_report_common.rml @@ -1,8 +1,8 @@ -