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
32 class report_account_receivable(osv.osv):
33 _name = "report.account.receivable"
34 _description = "Receivable accounts"
37 'name': fields.date('Month', readonly=True),
38 'user_id':fields.many2one('res.users', 'User', readonly=True, relate=True),
39 'section_id':fields.many2one('crm.case.section', 'Section', readonly=True, relate=True),
40 'amount_revenue': fields.float('Est.Revenue', readonly=True),
41 'amount_costs': fields.float('Est.Cost', readonly=True),
42 'amount_revenue_prob': fields.float('Est. Rev*Prob.', readonly=True),
43 'nbr': fields.integer('# of Cases', readonly=True),
44 'probability': fields.float('Avg. Probability', readonly=True),
45 'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True),
46 'delay_close': fields.integer('Delay to close', readonly=True),
48 _order = 'name desc, user_id, section_id'
51 create or replace view report_crm_case_user as (
54 substring(c.create_date for 7)||'-01' as name,
59 sum(planned_revenue) as amount_revenue,
60 sum(planned_cost) as amount_costs,
61 sum(planned_revenue*probability)::decimal(16,2) as amount_revenue_prob,
62 avg(probability)::decimal(16,2) as probability,
63 to_char(avg(date_closed-c.create_date), 'DD"d" HH12:MI:SS') as delay_close
66 group by substring(c.create_date for 7), c.state, c.user_id, c.section_id
68 report_crm_case_user()