2010-03-15 11:56:28 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# OpenERP, Open Source Management Solution
|
|
|
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
# License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
##############################################################################
|
2010-03-18 08:46:13 +00:00
|
|
|
|
2010-03-15 11:56:28 +00:00
|
|
|
from osv import fields,osv
|
|
|
|
import tools
|
|
|
|
|
2010-03-18 08:46:13 +00:00
|
|
|
|
2010-05-06 07:31:09 +00:00
|
|
|
AVAILABLE_STATES = [
|
|
|
|
('draft','Draft'),
|
|
|
|
('open','Open'),
|
|
|
|
('cancel', 'Cancelled'),
|
|
|
|
('done', 'Closed'),
|
|
|
|
('pending','Pending')
|
|
|
|
]
|
|
|
|
|
2010-03-15 11:56:28 +00:00
|
|
|
class crm_helpdesk_report(osv.osv):
|
2010-03-18 08:46:13 +00:00
|
|
|
""" Helpdesk report after Sales Services """
|
|
|
|
|
2010-03-15 11:56:28 +00:00
|
|
|
_name = "crm.helpdesk.report"
|
|
|
|
_description = "Helpdesk report after Sales Services"
|
|
|
|
_auto = False
|
2010-05-06 07:31:09 +00:00
|
|
|
|
2010-03-15 11:56:28 +00:00
|
|
|
_columns = {
|
2010-05-06 07:31:09 +00:00
|
|
|
'name': fields.char('Year', size=64, required=False, readonly=True),
|
|
|
|
'user_id':fields.many2one('res.users', 'User', readonly=True),
|
|
|
|
'section_id':fields.many2one('crm.case.section', 'Section', readonly=True),
|
|
|
|
'nbr': fields.integer('# of Cases', readonly=True),
|
|
|
|
'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True),
|
|
|
|
'month':fields.selection([('01', 'January'), ('02', 'February'), \
|
|
|
|
('03', 'March'), ('04', 'April'),\
|
|
|
|
('05', 'May'), ('06', 'June'), \
|
|
|
|
('07', 'July'), ('08', 'August'),\
|
|
|
|
('09', 'September'), ('10', 'October'),\
|
|
|
|
('11', 'November'), ('12', 'December')], 'Month', readonly=True),
|
2010-03-15 11:56:28 +00:00
|
|
|
'delay_close': fields.char('Delay to close', size=20, readonly=True),
|
2010-03-18 08:46:13 +00:00
|
|
|
'partner_id': fields.many2one('res.partner', 'Partner' , readonly=True),
|
|
|
|
'company_id': fields.many2one('res.company', 'Company', readonly=True),
|
2010-03-15 11:56:28 +00:00
|
|
|
'date_deadline': fields.date('Deadline'),
|
2010-03-18 08:46:13 +00:00
|
|
|
'priority': fields.selection([('5', 'Lowest'), ('4', 'Low'), \
|
|
|
|
('3', 'Normal'), ('2', 'High'), ('1', 'Highest')], 'Priority'),
|
2010-03-15 11:56:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
def init(self, cr):
|
2010-03-18 08:46:13 +00:00
|
|
|
|
2010-03-18 11:23:49 +00:00
|
|
|
"""
|
|
|
|
Display Deadline ,Responsible user, partner ,Department
|
|
|
|
@param cr: the current row, from the database cursor
|
|
|
|
"""
|
2010-03-18 08:46:13 +00:00
|
|
|
|
2010-03-15 11:56:28 +00:00
|
|
|
tools.drop_view_if_exists(cr, 'crm_helpdesk_report')
|
|
|
|
cr.execute("""
|
|
|
|
create or replace view crm_helpdesk_report as (
|
|
|
|
select
|
|
|
|
min(c.id) as id,
|
|
|
|
to_char(c.create_date, 'YYYY') as name,
|
|
|
|
to_char(c.create_date, 'MM') as month,
|
|
|
|
c.state,
|
|
|
|
c.user_id,
|
|
|
|
c.section_id,
|
|
|
|
c.partner_id,
|
|
|
|
c.company_id,
|
|
|
|
c.priority,
|
|
|
|
c.date_deadline,
|
|
|
|
count(*) as nbr,
|
|
|
|
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
|
|
|
|
from
|
|
|
|
crm_helpdesk c
|
2010-03-18 08:46:13 +00:00
|
|
|
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'),\
|
|
|
|
c.state, c.user_id,c.section_id,c.priority,\
|
|
|
|
c.partner_id,c.company_id,c.date_deadline
|
2010-03-15 11:56:28 +00:00
|
|
|
)""")
|
2010-03-18 08:46:13 +00:00
|
|
|
|
2010-03-15 11:56:28 +00:00
|
|
|
crm_helpdesk_report()
|
|
|
|
|
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|