1
##############################################################################
3
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
5
# $Id: project.py 1005 2005-07-25 08:41:42Z nicoe $
7
# WARNING: This program as such is intended to be used by professional
8
# programmers who take the whole responsability of assessing all potential
9
# consequences resulting from its eventual inadequacies and bugs
10
# End users who are looking for a ready-to-use solution with commercial
11
# garantees and support are strongly adviced to contract a Free Software
14
# This program is Free Software; you can redistribute it and/or
15
# modify it under the terms of the GNU General Public License
16
# as published by the Free Software Foundation; either version 2
17
# of the License, or (at your option) any later version.
19
# This program is distributed in the hope that it will be useful,
20
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
# GNU General Public License for more details.
24
# You should have received a copy of the GNU General Public License
25
# along with this program; if not, write to the Free Software
26
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28
##############################################################################
30
from osv import fields,osv
35
('cancel', 'Canceled'),
40
class report_crm_case_user(osv.osv):
41
_name = "report.crm.case.user"
42
_description = "Cases by user and section"
45
'name': fields.date('Month', readonly=True),
46
'user_id':fields.many2one('res.users', 'User', readonly=True, relate=True),
47
'section_id':fields.many2one('crm.case.section', 'Section', readonly=True, relate=True),
48
'amount_revenue': fields.float('Est.Revenue', readonly=True),
49
'amount_costs': fields.float('Est.Cost', readonly=True),
50
'amount_revenue_prob': fields.float('Est. Rev*Prob.', readonly=True),
51
'nbr': fields.integer('# of Cases', readonly=True),
52
'probability': fields.float('Avg. Probability', readonly=True),
53
'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True),
54
'delay_close': fields.integer('Delay to close', readonly=True),
56
_order = 'name desc, user_id, section_id'
59
create or replace view report_crm_case_user as (
62
substring(c.create_date for 7)||'-01' as name,
67
sum(planned_revenue) as amount_revenue,
68
sum(planned_cost) as amount_costs,
69
sum(planned_revenue*probability)::decimal(16,2) as amount_revenue_prob,
70
avg(probability)::decimal(16,2) as probability,
71
to_char(avg(date_closed-c.create_date), 'DD"d" HH12:MI:SS') as delay_close
74
group by substring(c.create_date for 7), c.state, c.user_id, c.section_id
76
report_crm_case_user()
78
class report_crm_case_categ(osv.osv):
79
_name = "report.crm.case.categ"
80
_description = "Cases by section and category"
83
'name': fields.date('Month', readonly=True),
84
'categ_id':fields.many2one('crm.case.categ', 'Category', readonly=True, relate=True),
85
'section_id':fields.many2one('crm.case.section', 'Section', readonly=True, relate=True),
86
'amount_revenue': fields.float('Est.Revenue', readonly=True),
87
'amount_costs': fields.float('Est.Cost', readonly=True),
88
'amount_revenue_prob': fields.float('Est. Rev*Prob.', readonly=True),
89
'nbr': fields.integer('# of Cases', readonly=True),
90
'probability': fields.float('Avg. Probability', readonly=True),
91
'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True),
92
'delay_close': fields.integer('Delay Close', readonly=True),
94
_order = 'name desc, categ_id, section_id'
97
create or replace view report_crm_case_categ as (
100
substring(c.create_date for 7)||'-01' as name,
105
sum(planned_revenue) as amount_revenue,
106
sum(planned_cost) as amount_costs,
107
sum(planned_revenue*probability)::decimal(16,2) as amount_revenue_prob,
108
avg(probability)::decimal(16,2) as probability,
109
to_char(avg(date_closed-c.create_date), 'DD"d" HH12:MI:SS') as delay_close
112
group by substring(c.create_date for 7), c.state, c.categ_id, c.section_id
114
report_crm_case_categ()