[ADD]: Add Analytic Entries SQL report.
bzr revid: rch_open_erp-20100504071213-evj2bri1m1r9fi07
This commit is contained in:
parent
9a4e39e63c
commit
24c309f335
|
@ -110,7 +110,8 @@ module named account_voucherss
|
|||
'report/account_entries_report_view.xml',
|
||||
'report/account_report_view.xml',
|
||||
'report/account_analytic_report_view.xml',
|
||||
'report/account_account_report_view.xml'
|
||||
'report/account_account_report_view.xml',
|
||||
'report/account_analytic_entries_report_view.xml'
|
||||
],
|
||||
'demo_xml': [
|
||||
#'demo/price_accuracy00.yml',
|
||||
|
|
|
@ -39,5 +39,6 @@ import account_report
|
|||
import account_analytic_report
|
||||
import account_account_report
|
||||
import account_entries_report
|
||||
import account_analytic_entries_report
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
# -*- 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 analytic_entries_report(osv.osv):
|
||||
_name = "analytic.entries.report"
|
||||
_description = "Analytic Entries Statistics"
|
||||
_auto = False
|
||||
_columns = {
|
||||
'date': fields.date('Date', 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),
|
||||
'user_id' : fields.many2one('res.users', 'User',readonly=True),
|
||||
'name': fields.char('Description', size=64, readonly=True),
|
||||
'company_id': fields.many2one('res.company', 'Company', required=True),
|
||||
'currency_id': fields.many2one('res.currency', 'Currency', required=True),
|
||||
'account_id': fields.many2one('account.analytic.account', 'Account', required=True),
|
||||
'general_account_id': fields.many2one('account.account', 'General Account', required=True),
|
||||
'journal_id': fields.many2one('account.analytic.journal', 'Journal', required=True),
|
||||
'move_id': fields.many2one('account.move.line', 'Move', required=True),
|
||||
'product_id': fields.many2one('product.product', 'Product', required=True),
|
||||
'product_uom_id': fields.many2one('product.uom', 'Product UOM', required=True),
|
||||
'amount': fields.float('Amount', readonly=True),
|
||||
'unit_amount': fields.float('Unit Amount', readonly=True),
|
||||
'amount_currency': fields.float('Amount Currency', readonly=True),
|
||||
}
|
||||
def init(self, cr):
|
||||
tools.drop_view_if_exists(cr, 'analytic_entries_report')
|
||||
cr.execute("""
|
||||
create or replace view analytic_entries_report as (
|
||||
select
|
||||
min(a.id) as id,
|
||||
a.create_date as date,
|
||||
to_char(a.create_date, 'YYYY') as year,
|
||||
to_char(a.create_date, 'MM') as month,
|
||||
to_char(a.create_date, 'YYYY-MM-DD') as day,
|
||||
a.user_id as user_id,
|
||||
a.name as name,
|
||||
a.company_id as company_id,
|
||||
a.currency_id as currency_id,
|
||||
a.account_id as account_id,
|
||||
a.general_account_id as general_account_id,
|
||||
a.journal_id as journal_id,
|
||||
a.move_id as move_id,
|
||||
a.product_id as product_id,
|
||||
a.product_uom_id as product_uom_id,
|
||||
sum(a.amount) as amount,
|
||||
sum(a.unit_amount) as unit_amount,
|
||||
sum(a.amount_currency) as amount_currency
|
||||
from
|
||||
account_analytic_line a
|
||||
group by
|
||||
a.create_date, a.user_id,a.name,company_id,a.currency_id,
|
||||
a.account_id,a.general_account_id,a.journal_id,
|
||||
a.move_id,a.product_id,a.product_uom_id
|
||||
)
|
||||
""")
|
||||
analytic_entries_report()
|
|
@ -0,0 +1,102 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_analytic_entries_report_tree" model="ir.ui.view">
|
||||
<field name="name">analytic.entries.report.tree</field>
|
||||
<field name="model">analytic.entries.report</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Analytic Entries Statistics">
|
||||
<field name="date" invisible="1"/>
|
||||
<field name="year" invisible="1"/>
|
||||
<field name="day" invisible="1"/>
|
||||
<field name="month" invisible="1"/>
|
||||
<field name="user_id" invisible="1"/>
|
||||
<field name="name" invisible="1"/>
|
||||
<field name="company_id" invisible="1" groups="base.multi_company"/>
|
||||
<field name="currency_id" invisible="1"/>
|
||||
<field name="account_id" invisible="1"/>
|
||||
<field name="general_account_id" invisible="1"/>
|
||||
<field name="journal_id" invisible="1"/>
|
||||
<field name="move_id" invisible="1"/>
|
||||
<field name="product_id" invisible="1"/>
|
||||
<field name="product_uom_id" invisible="1"/>
|
||||
<field name="amount" sum="Amount"/>
|
||||
<field name="unit_amount" sum="Unit Amount"/>
|
||||
<field name="amount_currency" sum="Amount Currency"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_analytic_entries_report_search" model="ir.ui.view">
|
||||
<field name="name">analytic.entries.report.search</field>
|
||||
<field name="model">analytic.entries.report</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Analytic Entries">
|
||||
<group col="10" colspan="12">
|
||||
<filter icon="terp-account" string="This Year"
|
||||
domain="[('day','<=', time.strftime('%%Y-%%m-%%d')),('day','>',(datetime.date.today()-datetime.timedelta(days=365)).strftime('%%Y-%%m-%%d'))]"
|
||||
help="Analytic Entries of the year"/>
|
||||
<filter icon="terp-account" string="This Month"
|
||||
name="month"
|
||||
domain="[('day','<=', time.strftime('%%Y-%%m-%%d')), ('day','>',(datetime.date.today()-datetime.timedelta(days=30)).strftime('%%Y-%%m-%%d'))]"
|
||||
help="Analytic Entries of this month"/>
|
||||
<filter icon="gtk-media-rewind"
|
||||
string=" 7 Days "
|
||||
separator="1"
|
||||
domain="[('day','<=', time.strftime('%%Y-%%m-%%d')), ('day','>',(datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]"
|
||||
help="Analytic Entries during last 7 days"/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="name"/>
|
||||
<field name="user_id" widget="selection">
|
||||
<filter icon="terp-partner" domain="[('user_id','=',uid)]" help="My Case"/>
|
||||
</field>
|
||||
<field name="currency_id"/>
|
||||
<field name="company_id" widget="selection" groups="base.multi_company"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="0" string="Extended options..." colspan="10" col="12">
|
||||
<field name="account_id" />
|
||||
<field name="general_account_id" widget="selection"/>
|
||||
<field name="journal_id" widget="selection"/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="move_id"/>
|
||||
<field name="product_id" />
|
||||
<field name="product_uom_id" widget="selection"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="1" string="Group By..." colspan="10" col="12">
|
||||
<filter string="User" icon="terp-account" context="{'group_by':'user_id'}"/>
|
||||
<filter string="Currency" icon="terp-account" context="{'group_by':'currency_id'}"/>
|
||||
<filter string="Company" icon="terp-account" context="{'group_by':'company_id'}" groups="base.multi_company"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter string="Account" name="Account" icon="terp-account" context="{'group_by':'account_id'}"/>
|
||||
<filter string="General Account" icon="terp-account" context="{'group_by':'general_account_id'}"/>
|
||||
<filter string="Journal" icon="terp-account" context="{'group_by':'journal_id'}"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter string="Move" icon="terp-account" context="{'group_by':'move_id'}"/>
|
||||
<filter string="Product" icon="terp-account" context="{'group_by':'product_id'}"/>
|
||||
<filter string="Product UOM" icon="terp-account" context="{'group_by':'product_uom_id'}"/>
|
||||
<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_analytic_entries_report" model="ir.actions.act_window">
|
||||
<field name="name">Analytic Entries</field>
|
||||
<field name="res_model">analytic.entries.report</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,graph</field>
|
||||
<field name="context">{'search_default_month':1,'search_default_Account':1,'group_by_no_leaf':1,'group_by':[]}</field>
|
||||
<field name="search_view_id" ref="view_analytic_entries_report_search"/>
|
||||
</record>
|
||||
|
||||
<menuitem action="action_analytic_entries_report" id="menu_action_analytic_entries_report" parent="account.menu_finance_reporting" />
|
||||
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue