From c445b5b47185e3039456b784a9ea11500ddcd289 Mon Sep 17 00:00:00 2001 From: "rch (Open ERP)" <> Date: Tue, 27 Apr 2010 18:00:23 +0530 Subject: [PATCH] [Add]: Add SQL view report for Accounts. bzr revid: rch_open_erp-20100427123023-npkej0o1ed0viscq --- addons/account/__openerp__.py | 1 + addons/account/report/__init__.py | 2 +- .../account/report/account_account_report.py | 77 +++++++++++++++++ .../report/account_account_report_view.xml | 83 +++++++++++++++++++ addons/account/report/account_report_view.xml | 8 +- 5 files changed, 166 insertions(+), 5 deletions(-) create mode 100644 addons/account/report/account_account_report.py create mode 100644 addons/account/report/account_account_report_view.xml diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index abd3d1f459d..e73b3885089 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -100,6 +100,7 @@ module named account_voucherss 'report/account_invoice_report_view.xml', 'report/account_report_view.xml', 'report/account_analytic_report_view.xml', + 'report/account_account_report_view.xml' ], 'demo_xml': [ #'demo/price_accuracy00.yml', diff --git a/addons/account/report/__init__.py b/addons/account/report/__init__.py index 09ff866d1a8..959a76013f9 100644 --- a/addons/account/report/__init__.py +++ b/addons/account/report/__init__.py @@ -37,6 +37,6 @@ import compare_account_balance import account_invoice_report import account_report import account_analytic_report - +import account_account_report # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/account_account_report.py b/addons/account/report/account_account_report.py new file mode 100644 index 00000000000..a872a7173e7 --- /dev/null +++ b/addons/account/report/account_account_report.py @@ -0,0 +1,77 @@ +# -*- 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 . +# +############################################################################## + +import tools +from osv import fields,osv + +class account_account_report(osv.osv): + _name = "account.account.report" + _description = "Account Report" + _auto = False + _columns = { + 'name': fields.char('Name', size=128, readonly=True), + 'code': fields.char('Code', size=64, readonly=True), + 'type': fields.selection([ + ('receivable', 'Receivable'), + ('payable', 'Payable'), + ('view', 'View'), + ('consolidation', 'Consolidation'), + ('other', 'Others'), + ('closed', 'Closed'), + ], 'Internal Type', readonly=True), + 'company_id': fields.many2one('res.company', 'Company', required=True), + 'currency_mode': fields.selection([('current', 'At Date'), ('average', 'Average Rate')], 'Outgoing Currencies Rate',readonly=True), + 'user_type': fields.many2one('account.account.type', 'Account Type',readonly=True), + 'credit': fields.float('Credit', readonly=True), + 'debit': fields.float('Debit', readonly=True), + 'balance': fields.float('Balance', readonly=True) + } + def init(self, cr): + tools.drop_view_if_exists(cr, 'account_account_report') + cr.execute(""" + create or replace view account_account_report as ( + select + min(a.id) as id, + a.name, + a.code, + a.type as type, + a.company_id as company_id, + a.currency_mode as currency_mode, + a.user_type as user_type, + sum(m.credit) as credit, + sum(m.debit) as debit, + (sum(m.credit)-sum(m.debit)) as balance + from + account_account as a + left join + account_move_line as m + on m.account_id=a.id + group by + a.name, + a.code, + a.type, + a.company_id, + a.currency_mode, + a.user_type, + m.account_id + ) + """) +account_account_report() diff --git a/addons/account/report/account_account_report_view.xml b/addons/account/report/account_account_report_view.xml new file mode 100644 index 00000000000..a2b4903c8d9 --- /dev/null +++ b/addons/account/report/account_account_report_view.xml @@ -0,0 +1,83 @@ + + + + + account.account.report.tree + account.account.report + tree + + + + + + + + + + + + + + + + + account.account.report.graph + account.account.report + graph + + + + + + + + + + + + account.account.report.search + account.account.report + search + + + + + + + + + + + + + + + + + + + + + + + + + + + + Accounts + account.account.report + form + tree,graph + {"search_default_Company":1,"search_default_At Date":1,'group_by_no_leaf':1,'group_by':[]} + + + + + + + diff --git a/addons/account/report/account_report_view.xml b/addons/account/report/account_report_view.xml index f0f67b477e3..9b1688730aa 100644 --- a/addons/account/report/account_report_view.xml +++ b/addons/account/report/account_report_view.xml @@ -47,7 +47,7 @@ form tree,graph - + @@ -116,7 +116,7 @@ - + report.account.sales.tree @@ -169,7 +169,7 @@ graph,tree - + @@ -237,7 +237,7 @@ graph,tree - +