[ADD]: Add SQL report for Entries.

bzr revid: rch_open_erp-20100429124540-b49s7pibrjk4r4i3
This commit is contained in:
aag (Open ERP) 2010-04-29 18:15:40 +05:30 committed by rch (Open ERP)
parent 889d4d7ebc
commit 565ba12d6c
4 changed files with 204 additions and 0 deletions

View File

@ -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'

View File

@ -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:

View File

@ -0,0 +1,96 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 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 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()

View File

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_entries_report_tree" model="ir.ui.view">
<field name="name">account.entries.report.tree</field>
<field name="model">account.entries.report</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Invoices Statistics">
<field name="date" invisible="1"/>
<field name="ref" invisible="1"/>
<field name="state" invisible="1"/>
<field name="year" invisible="1"/>
<field name="day" invisible="1"/>
<field name="month" invisible="1"/>
<field name="nbr" sum="# of Entries "/>
<field name="nbl" sum="# of Lines "/>
<field name="amount" sum="# of Amount "/>
<field name="partner_id" invisible="1"/>
<field name="company_id" invisible="1"/>
<field name="journal_id" invisible="1"/>
<field name="period_id" invisible="1"/>
<field name="type" invisible="1"/>
</tree>
</field>
</record>
<record id="view_account_entries_report_graph" model="ir.ui.view">
<field name="name">account.entries.report.graph</field>
<field name="model">account.entries.report</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Entries" type="bar">
<field name="partner_id"/>
<field name="amount"/>
</graph>
</field>
</record>
<record id="view_account_entries_report_search" model="ir.ui.view">
<field name="name">account.entries.report.search</field>
<field name="model">account.entries.report</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Entries">
<group>
<filter icon="terp-account" string="This Year"
domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')),('date','&gt;',(datetime.date.today()-datetime.timedelta(days=365)).strftime('%%Y-%%m-%%d'))]"
help="Entries of the year"/>
<filter icon="terp-account" string="This Month"
name="This Month"
domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')), ('date','&gt;',(datetime.date.today()-datetime.timedelta(days=30)).strftime('%%Y-%%m-%%d'))]"
help="Entries of this month"/>
<filter icon="gtk-media-rewind"
string=" 7 Days "
separator="1"
domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')), ('date','&gt;',(datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]"
help="Entries during last 7 days"/>
<separator orientation="vertical"/>
<filter string="Draft"
icon="terp-account"
domain="[('state','=','draft')]"
help = "Draft tasks"/>
<separator orientation="vertical"/>
<field name="journal_id" widget="selection"/>
<field name="company_id" widget="selection"/>
<field name="partner_id" />
</group>
<newline/>
<group expand="0" string="Extended options..." colspan="10" col="12">
<filter string="Posted"
icon="terp-account"
domain="[('state','=','posted')]"
help = "Posted tasks"/>
<separator orientation="vertical"/>
<field name="period_id" widget="selection"/>
<field name="type"/>
<separator orientation="vertical"/>
<field name="date"/>
</group>
<newline/>
<group expand="1" string="Group By..." colspan="10" col="12">
<filter string="Journal" name="Journal" icon="terp-account" context="{'group_by':'journal_id'}"/>
<filter string="Company" icon="terp-account" context="{'group_by':'company_id'}" />
<filter string="Partner" icon="terp-account" context="{'group_by':'partner_id'}"/>
<separator orientation="vertical"/>
<filter string="State" icon="terp-account" context="{'group_by':'state'}"/>
<filter string="Period" icon="terp-account" context="{'group_by':'period_id'}"/>
<filter string="Type" icon="terp-account" context="{'group_by':'type'}"/>
<separator orientation="vertical"/>
<filter string="Day" icon="terp-account" context="{'group_by':'day'}"/>
<filter string="Month" icon="terp-account" context="{'group_by':'month'}"/>
<filter string="Year" icon="terp-account" context="{'group_by':'year'}"/>
</group>
</search>
</field>
</record>
<record id="action_account_entries_report_all" model="ir.actions.act_window">
<field name="name">Entries</field>
<field name="res_model">account.entries.report</field>
<field name="view_type">form</field>
<field name="view_mode">tree,graph</field>
<field name="context">{'search_default_This Month':1,'search_default_Journal':1,'group_by_no_leaf':1,'group_by':[]}</field>
<field name="search_view_id" ref="view_account_entries_report_search"/>
</record>
<menuitem action="action_account_entries_report_all" id="menu_action_account_entries_report_all" parent="account.menu_finance_reporting" sequence="0"/>
</data>
</openerp>