diff options
| author | Ujjvala Collins (OpenERP) <uco@tinyerp.com> | 2011-08-12 16:53:21 +0530 |
|---|---|---|
| committer | Ujjvala Collins (OpenERP) <uco@tinyerp.com> | 2011-08-12 16:53:21 +0530 |
| commit | d4ee49e658a90657da2dc848c40e2dd31d5cd71d (patch) | |
| tree | af9653ac84fbeb752557407effa9fff0f6bf9fd2 | |
| parent | 27a0a2c059e3cf5cbca02700b9f4ffb8c30150d0 (diff) | |
[IMP] account: Improved report.
bzr revid: uco@tinyerp.com-20110812112321-3q1vfylgojz0s91h
| -rw-r--r-- | addons/account/account.py | 28 | ||||
| -rw-r--r-- | addons/account/account_menuitem.xml | 1 | ||||
| -rw-r--r-- | addons/account/account_view.xml | 49 | ||||
| -rw-r--r-- | addons/account/report/__init__.py | 1 | ||||
| -rw-r--r-- | addons/account/report/account_report_common.py | 83 | ||||
| -rw-r--r-- | addons/account/report/account_report_common.rml | 187 | ||||
| -rw-r--r-- | addons/account/wizard/account_report.py | 28 | ||||
| -rw-r--r-- | addons/account/wizard/account_report_view.xml | 24 |
8 files changed, 371 insertions, 30 deletions
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 @@ <menuitem id="base.menu_action_currency_form" parent="menu_configuration_misc" sequence="20"/> <menuitem id="menu_finance_generic_reporting" name="Generic Reporting" parent="menu_finance_reporting" sequence="100"/> <menuitem id="menu_finance_entries" name="Journal Entries" parent="menu_finance" sequence="5" groups="group_account_user,group_account_manager"/> + <menuitem id="menu_account_reports" name="Reports" parent="menu_finance_accounting" sequence="18"/> <menuitem id="account.menu_finance_recurrent_entries" name="Recurring Entries" parent="menu_finance_periodical_processing" sequence="15" diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 19def9fff12..abf2c3b775f 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -2703,5 +2703,54 @@ action = self.pool.get('res.config').next(cr, uid, [], context) parent="menu_finance_payables" action="base.action_partner_supplier_form" sequence="100"/> + <!-- + Account Reports + --> + + <record id="view_account_report_form" model="ir.ui.view"> + <field name="name">account.report.form</field> + <field name="model">account.report</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Account Report"> + <field name="name"/> + <field name="parent_id"/> + <field name="sequence"/> + <field name="type"/> + <field name="account_report_id"/> + <separator string="Accounts" colspan="4"/> + <field name="account_ids" nolabel="1" colspan="4"/> + <separator string="Notes" colspan="4"/> + <field name="note" nolabel="1" colspan="4"/> + </form> + </field> + </record> + + <record id="view_account_report_tree" model="ir.ui.view"> + <field name="name">account.report.tree</field> + <field name="model">account.report</field> + <field name="type">tree</field> + <field name="arch" type="xml"> + <tree string="Account Report"> + <field name="sequence"/> + <field name="name"/> + <field name="parent_id"/> + <field name="type"/> + <field name="account_report_id"/> + </tree> + </field> + </record> + + <record id="action_account_report_tree" model="ir.actions.act_window"> + <field name="name">Account Reports</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">account.report</field> + <field name="view_type">form</field> + <field name="view_mode">tree,form</field> + <field name="view_id" ref="view_account_report_tree"/> + </record> + + <menuitem id="menu_account_reports_tree" name="Account Reports" parent="menu_account_reports" action="action_account_report_tree"/> + </data> </openerp> 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 (<http://tiny.be>). +# +# 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 <http://www.gnu.org/licenses/>. +# +############################################################################## + +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 @@ +<?xml version="1.0"?> +<document filename="Account Reports.pdf"> + <template pageSize="(595.0,842.0)" title="Account Reports" author="Martin Simon" allowSplitting="20"> + <pageTemplate id="first"> + <frame id="first" x1="57.0" y1="57.0" width="481" height="728"/> + </pageTemplate> + </template> + <stylesheet> + <blockTableStyle id="Standard_Outline"> + <blockAlignment value="LEFT"/> + <blockValign value="TOP"/> + </blockTableStyle> + <blockTableStyle id="Table1"> + <blockAlignment value="LEFT"/> + <blockValign value="TOP"/> + <lineStyle kind="GRID" colorName="black"/> + </blockTableStyle> + <blockTableStyle id="Table2"> + <blockAlignment value="LEFT"/> + <blockValign value="TOP"/> + <lineStyle kind="GRID" colorName="black"/> + </blockTableStyle> + <blockTableStyle id="Table8"> + <blockAlignment value="LEFT"/> + <blockValign value="TOP"/> + <lineStyle kind="GRID" colorName="black"/> + </blockTableStyle> + <blockTableStyle id="Table10"> + <blockAlignment value="LEFT"/> + <blockValign value="TOP"/> + <lineStyle kind="GRID" colorName="black"/> + </blockTableStyle> + <blockTableStyle id="Table11"> + <blockAlignment value="LEFT"/> + <blockValign value="TOP"/> + </blockTableStyle> + <blockTableStyle id="Table3"> + <blockAlignment value="LEFT"/> + <blockValign value="TOP"/> + <lineStyle kind="GRID" colorName="black"/> + </blockTableStyle> + <initialize> + <paraStyle name="all" alignment="justify"/> + </initialize> + <paraStyle name="P1" fontName="Helvetica" fontSize="11.0" leading="14" alignment="CENTER"/> + <paraStyle name="P2" fontName="Helvetica-Bold" fontSize="11.0" leading="14" alignment="CENTER"/> + <paraStyle name="P3" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/> + <paraStyle name="P4" fontName="Helvetica" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> + <paraStyle name="P5" fontName="Helvetica-Bold" fontSize="2.0" leading="3" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> + <paraStyle name="P6" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> + <paraStyle name="Standard" fontName="Times-Roman"/> + <paraStyle name="Heading" fontName="Helvetica" fontSize="14.0" leading="17" spaceBefore="12.0" spaceAfter="6.0"/> + <paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/> + <paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/> + <paraStyle name="Caption" fontName="Times-Roman" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/> + <paraStyle name="Index" fontName="Times-Roman"/> + <paraStyle name="Preformatted Text" fontName="Helvetica" fontSize="10.0" leading="13" spaceBefore="0.0" spaceAfter="0.0"/> + <paraStyle name="Table Contents" fontName="Times-Roman"/> + <paraStyle name="terp_header" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/> + <paraStyle name="terp_tblheader_General" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="6.0" spaceAfter="6.0"/> + <paraStyle name="terp_tblheader_General_Centre" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/> + <paraStyle name="terp_default_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> + <paraStyle name="terp_default_Centre_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> + <paraStyle name="terp_tblheader_Details" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> + <paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER"/> + </stylesheet> + <story> + <para style="Preformatted Text"> + <font color="white"> </font> + </para> + <blockTable colWidths="56.0,53.0,380.0" style="Table8"> + <tr> + <td> + <para style="P3">Chart of Account</para> + </td> + <td> + <para style="P3">Fiscal Year</para> + </td> + <td> + <para style="P3">Filters By [[ get_filter(data)!='No Filter' and get_filter(data) ]]</para> + </td> + </tr> + <tr> + <td> + <para style="terp_default_Centre_8">[[ get_account(data) or '' ]]</para> + </td> + <td> + <para style="terp_default_Centre_8">[[ get_fiscalyear(data) or '' ]]</para> + </td> + <td> + <blockTable colWidths="179.0,195.0" style="Table10"> + <tr> + <td> + <para style="P5">[[ get_filter(data)=='Date' or removeParentNode('blockTable') ]]</para> + <para style="P6">Start Date</para> + </td> + <td> + <para style="P6">End Date</para> + </td> + </tr> + <tr> + <td> + <para style="terp_default_Centre_8">[[ get_start_date(data) ]]</para> + </td> + <td> + <para style="terp_default_Centre_8">[[ get_end_date(data) ]]</para> + </td> + </tr> + </blockTable> + <blockTable colWidths="176.0,195.0" style="Table11"> + <tr> + <td> + <para style="P5">[[ get_filter(data)=='Periods' or removeParentNode('blockTable')]] </para> + <para style="P6">]]Start Period</para> + </td> + <td> + <para style="P6">End Period</para> + </td> + </tr> + <tr> + <td> + <para style="P4">[[ get_start_period(data) or removeParentNode('para') ]]</para> + </td> + <td> + <para style="P4">[[ get_end_period(data) or removeParentNode('para') ]]</para> + </td> + </tr> + </blockTable> + <para style="terp_default_Centre_8"> + <font color="white"> </font> + </para> + </td> + </tr> + </blockTable> + <para style="Preformatted Text"> + <font color="white"> </font> + </para> + <blockTable colWidths="490.0" style="Table1"> + <para style="P2">[[ repeatIn(get_report_name(data),'r') ]] </para> + <tr> + <td> + <para style="P2">[[ r['name'] ]]</para> + <blockTable colWidths="482.0" style="Table2"> + <tr> + <td> + <para style="P3">Account Details</para> + </td> + </tr> + </blockTable> + <blockTable colWidths="95.0,223.0,163.0" style="Table3"> + <tr> + <td> + <para style="P3">Code</para> + </td> + <td> + <para style="P3">Name</para> + </td> + <td> + <para style="P3">Balance</para> + </td> + </tr> + <tr> + <td> + <para style="terp_default_8"> + [[ repeatIn(get_account_details(r['id']), 'a') ]] [[ a['code'] ]] + </para> + </td> + <td> + <para style="terp_default_8"> + [[ a['name'] ]] + </para> + </td> + <td> + <para style="terp_default_8"> + [[ a['bal'] ]] + </para> + </td> + </tr> + </blockTable> + </td> + </tr> + </blockTable> + <para style="Standard"> + <font color="white"> </font> + </para> + </story> +</document> 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 @@ <openerp> <data> - <record id="account_report_view" model="ir.ui.view"> + <record id="accounting_report_view" model="ir.ui.view"> <field name="name">Account Report</field> - <field name="model">account.report</field> + <field name="model">accounting.report</field> <field name="type">form</field> <field name="inherit_id" ref="account.account_common_report_view"/> <field name="arch" type="xml"> - <xpath expr="//field[@name='chart_account_id']" position="replace"> - <field name="account_report_id"/> - <field name="sequence"/> - <field name="type"/> - </xpath> - <xpath expr="//field[@name='target_move']" position="replace"> + <xpath expr="//field[@name='target_move']" position="after"> + <field name="account_report_id" domain="[('parent_id','=',False)]"/> <field name="enable_comparison"/> + <field name="display_details_per_account"/> </xpath> <xpath expr="//notebook/page[@string='Filters']" position="replace"> <page string="Comparison" attrs="{'invisible': [('enable_comparison','=',False)]}"> @@ -28,25 +25,22 @@ </page> </xpath> <xpath expr="//notebook/page[@string='Journals']" position="replace"> - <page string="Accounts"> - <field name="account_ids" nolabel="1"/> - </page> </xpath> </field> </record> <record id="action_account_report" model="ir.actions.act_window"> - <field name="name">Mail Report</field> - <field name="res_model">account.report</field> + <field name="name">Report</field> + <field name="res_model">accounting.report</field> <field name="type">ir.actions.act_window</field> <field name="view_type">form</field> <field name="view_mode">form</field> - <field name="view_id" ref="account_report_view"/> + <field name="view_id" ref="accounting_report_view"/> <field name="target">new</field> </record> <menuitem icon="STOCK_PRINT" - name="Mail Report" + name="Report" action="action_account_report" groups="group_account_user,group_account_manager" id="menu_account_report" |
