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 ##############################################################################
22 from osv import fields,osv
25 class crm_phonecall_report(osv.osv):
26 """ Phone calls by user and section """
28 _name = "crm.phonecall.report"
29 _description = "Phone calls by user and section"
31 # _inherit = "crm.case.report"
34 'delay_close': fields.float('Delay to close', digits=(16,2),readonly=True, group_operator="avg",help="Number of Days to close the case"),
35 'categ_id': fields.many2one('crm.case.categ', 'Category', \
36 domain="[('section_id','=',section_id),\
37 ('object_id.model', '=', 'crm.phonecall')]"),
38 'partner_id': fields.many2one('res.partner', 'Partner' , readonly=True),
39 'company_id': fields.many2one('res.company', 'Company', readonly=True),
44 """ Phone Calls By User And Section
45 @param cr: the current row, from the database cursor,
48 tools.drop_view_if_exists(cr, 'crm_phonecall_report')
50 create or replace view crm_phonecall_report as (
53 to_char(c.create_date, 'YYYY') as name,
54 to_char(c.create_date, 'MM') as month,
55 to_char(c.create_date, 'YYYY-MM-DD') as day,
66 date_trunc('day',c.create_date) as create_date,
67 avg(extract('epoch' from (c.date_closed-c.create_date)))/(3600*24) as delay_close
70 group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'),\
71 c.state, c.user_id,c.section_id, c.categ_id,c.partner_id,c.company_id
72 ,to_char(c.create_date, 'YYYY-MM-DD'),c.create_date
75 crm_phonecall_report()
77 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: