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