From 565ba12d6cd0441f2940ea34379d443ef362a2d4 Mon Sep 17 00:00:00 2001 From: "aag (Open ERP)" <> Date: Thu, 29 Apr 2010 18:15:40 +0530 Subject: [PATCH] [ADD]: Add SQL report for Entries. bzr revid: rch_open_erp-20100429124540-b49s7pibrjk4r4i3 --- addons/account/__openerp__.py | 1 + addons/account/report/__init__.py | 1 + .../account/report/account_entries_report.py | 96 ++++++++++++++++ .../report/account_entries_report_view.xml | 106 ++++++++++++++++++ 4 files changed, 204 insertions(+) create mode 100644 addons/account/report/account_entries_report.py create mode 100644 addons/account/report/account_entries_report_view.xml diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index e73b3885089..e87818d40fc 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -98,6 +98,7 @@ module named account_voucherss 'company_view.xml', 'account_installer.xml', 'report/account_invoice_report_view.xml', + 'report/account_entries_report_view.xml', 'report/account_report_view.xml', 'report/account_analytic_report_view.xml', 'report/account_account_report_view.xml' diff --git a/addons/account/report/__init__.py b/addons/account/report/__init__.py index 959a76013f9..51cb0810f43 100644 --- a/addons/account/report/__init__.py +++ b/addons/account/report/__init__.py @@ -38,5 +38,6 @@ import account_invoice_report import account_report import account_analytic_report import account_account_report +import account_entries_report # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/account_entries_report.py b/addons/account/report/account_entries_report.py new file mode 100644 index 00000000000..83602ded81b --- /dev/null +++ b/addons/account/report/account_entries_report.py @@ -0,0 +1,96 @@ +# -*- 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_entries_report(osv.osv): + _name = "account.entries.report" + _description = "Entries" + _auto = False + _rec_name = 'date' + _columns = { + 'date': fields.date('Date', readonly=True), + 'nbr':fields.integer('# of Entries', readonly=True), + 'nbl':fields.integer('# of Lines', readonly=True), + 'amount': fields.float('Amount',readonly=True), + 'year': fields.char('Year', size=4, readonly=True), + 'day': fields.char('Day', size=128, readonly=True), + 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), + ('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'), + ('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True), + 'ref': fields.char('Reference', size=64,readonly=True), + 'period_id': fields.many2one('account.period', 'Period', readonly=True), + 'journal_id': fields.many2one('account.journal', 'Journal', readonly=True), + 'state': fields.selection([('draft','Draft'), ('posted','Posted')], 'State',readonly=True, + help='When new account move is created the state will be \'Draft\'. When all the payments are done it will be in \'Posted\' state.'), + 'partner_id': fields.many2one('res.partner','Partner', readonly=True), + 'type': fields.selection([ + ('pay_voucher','Cash Payment'), + ('bank_pay_voucher','Bank Payment'), + ('rec_voucher','Cash Receipt'), + ('bank_rec_voucher','Bank Receipt'), + ('cont_voucher','Contra'), + ('journal_sale_vou','Journal Sale'), + ('journal_pur_voucher','Journal Purchase'), + ('journal_voucher','Journal Voucher'), + ],'Type',readonly=True), + 'company_id': fields.many2one('res.company', 'Company', readonly=True), + } + _order = 'date desc' + + def init(self, cr): + tools.drop_view_if_exists(cr, 'account_entries_report') + cr.execute(""" + create or replace view account_entries_report as ( + select + min(l.id) as id, + am.ref as ref, + am.state as state, + am.date as date, + count(l.id) as nbr, + count(distinct am.id) as nbl, + l.debit as amount, + to_char(am.date, 'YYYY') as year, + to_char(am.date, 'MM') as month, + to_char(am.date, 'YYYY-MM-DD') as day, + am.company_id as company_id, + am.journal_id as journal_id, + am.period_id as period_id, + l.partner_id as partner_id, + am.type as type + from + account_move_line l + left join + account_move am on (am.id=l.move_id) + group by am.ref, + am.state, + am.date, + am.company_id, + am.journal_id, + am.period_id, + am.type, + l.partner_id, + l.debit + ) + """) + +account_entries_report() diff --git a/addons/account/report/account_entries_report_view.xml b/addons/account/report/account_entries_report_view.xml new file mode 100644 index 00000000000..46f7ac46b83 --- /dev/null +++ b/addons/account/report/account_entries_report_view.xml @@ -0,0 +1,106 @@ + + + + + account.entries.report.tree + account.entries.report + tree + + + + + + + + + + + + + + + + + + + + + account.entries.report.graph + account.entries.report + graph + + + + + + + + + account.entries.report.search + account.entries.report + search + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Entries + account.entries.report + form + tree,graph + {'search_default_This Month':1,'search_default_Journal':1,'group_by_no_leaf':1,'group_by':[]} + + + + +