1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##############################################################################
23 from osv import fields,osv
25 class analytic_entries_report(osv.osv):
26 _name = "analytic.entries.report"
27 _description = "Analytic Entries Statistics"
30 'date': fields.date('Date', readonly=True),
31 'year': fields.char('Year', size=4, readonly=True),
32 'day': fields.char('Day', size=128, readonly=True),
33 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'),
34 ('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'),
35 ('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True),
36 'user_id': fields.many2one('res.users', 'User',readonly=True),
37 'name': fields.char('Description', size=64, readonly=True),
38 'partner_id': fields.many2one('res.partner', 'Partner'),
39 'company_id': fields.many2one('res.company', 'Company', required=True),
40 'currency_id': fields.many2one('res.currency', 'Currency', required=True),
41 'account_id': fields.many2one('account.analytic.account', 'Account', required=False),
42 'general_account_id': fields.many2one('account.account', 'General Account', required=True),
43 'journal_id': fields.many2one('account.analytic.journal', 'Journal', required=True),
44 'move_id': fields.many2one('account.move.line', 'Move', required=True),
45 'product_id': fields.many2one('product.product', 'Product', required=True),
46 'product_uom_id': fields.many2one('product.uom', 'Product Unit of Measure', required=True),
47 'amount': fields.float('Amount', readonly=True),
48 'unit_amount': fields.float('Quantity', readonly=True),
49 'nbr': fields.integer('#Entries', readonly=True),
52 tools.drop_view_if_exists(cr, 'analytic_entries_report')
54 create or replace view analytic_entries_report as (
57 count(distinct a.id) as nbr,
59 to_char(a.date, 'YYYY') as year,
60 to_char(a.date, 'MM') as month,
61 to_char(a.date, 'YYYY-MM-DD') as day,
64 analytic.partner_id as partner_id,
65 a.company_id as company_id,
66 a.currency_id as currency_id,
67 a.account_id as account_id,
68 a.general_account_id as general_account_id,
69 a.journal_id as journal_id,
71 a.product_id as product_id,
72 a.product_uom_id as product_uom_id,
73 sum(a.amount) as amount,
74 sum(a.unit_amount) as unit_amount
76 account_analytic_line a, account_analytic_account analytic
77 where analytic.id = a.account_id
79 a.date, a.user_id,a.name,analytic.partner_id,a.company_id,a.currency_id,
80 a.account_id,a.general_account_id,a.journal_id,
81 a.move_id,a.product_id,a.product_uom_id
84 analytic_entries_report()
86 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: