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 openerp import tools
23 from openerp.addons.crm import crm
24 from openerp.osv import fields, osv
29 ('cancel', 'Cancelled'),
31 ('pending', 'Pending')
35 class crm_phonecall_report(osv.osv):
36 """ Phone calls by user and section """
38 _name = "crm.phonecall.report"
39 _description = "Phone calls by user and section"
43 'user_id':fields.many2one('res.users', 'User', readonly=True),
44 'section_id':fields.many2one('crm.case.section', 'Section', readonly=True),
45 'priority': fields.selection([('0','Low'), ('1','Normal'), ('2','High')], 'Priority'),
46 'nbr': fields.integer('# of Cases', readonly=True),
47 'state': fields.selection(AVAILABLE_STATES, 'Status', readonly=True),
48 'create_date': fields.datetime('Create Date', readonly=True, select=True),
49 'delay_close': fields.float('Delay to close', digits=(16,2),readonly=True, group_operator="avg",help="Number of Days to close the case"),
50 'duration': fields.float('Duration', digits=(16,2),readonly=True, group_operator="avg"),
51 'delay_open': fields.float('Delay to open',digits=(16,2),readonly=True, group_operator="avg",help="Number of Days to open the case"),
52 'categ_id': fields.many2one('crm.case.categ', 'Category', \
53 domain="[('section_id','=',section_id),\
54 ('object_id.model', '=', 'crm.phonecall')]"),
55 'partner_id': fields.many2one('res.partner', 'Partner' , readonly=True),
56 'company_id': fields.many2one('res.company', 'Company', readonly=True),
57 'opening_date': fields.date('Opening Date', readonly=True, select=True),
58 'date_closed': fields.date('Close Date', readonly=True, select=True),
63 """ Phone Calls By User And Section
64 @param cr: the current row, from the database cursor,
66 tools.drop_view_if_exists(cr, 'crm_phonecall_report')
68 create or replace view crm_phonecall_report as (
71 date(c.date_open) as opening_date,
72 date(c.date_closed) as date_closed,
82 c.create_date as create_date,
83 extract('epoch' from (c.date_closed-c.create_date))/(3600*24) as delay_close,
84 extract('epoch' from (c.date_open-c.create_date))/(3600*24) as delay_open
89 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: