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 team """
38 _name = "crm.phonecall.report"
39 _description = "Phone calls by user and team"
43 'user_id':fields.many2one('res.users', 'User', readonly=True),
44 'team_id':fields.many2one('crm.team', 'Sales Team', oldname='section_id', readonly=True),
45 'priority': fields.selection([('0','Low'), ('1','Normal'), ('2','High')], 'Priority'),
46 'nbr': fields.integer('# of Cases', readonly=True), # TDE FIXME master: rename into nbr_cases
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.phonecall.category', 'Category'),
53 'partner_id': fields.many2one('res.partner', 'Partner' , readonly=True),
54 'company_id': fields.many2one('res.company', 'Company', readonly=True),
55 'opening_date': fields.datetime('Opening Date', readonly=True, select=True),
56 'date_closed': fields.datetime('Close Date', readonly=True, select=True),
61 """ Phone Calls By User And Team
62 @param cr: the current row, from the database cursor,
64 tools.drop_view_if_exists(cr, 'crm_phonecall_report')
66 create or replace view crm_phonecall_report as (
69 c.date_open as opening_date,
70 c.date_closed as date_closed,
80 c.create_date as create_date,
81 extract('epoch' from (c.date_closed-c.create_date))/(3600*24) as delay_close,
82 extract('epoch' from (c.date_open-c.create_date))/(3600*24) as delay_open
87 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: