2010-01-20 08:41:20 +00:00
|
|
|
from osv import fields,osv
|
|
|
|
import tools
|
|
|
|
|
2010-03-03 07:14:05 +00:00
|
|
|
class report_crm_phonecall(osv.osv):
|
|
|
|
_name = "report.crm.phonecall"
|
2010-01-20 08:41:20 +00:00
|
|
|
_description = "Phone calls by user and section"
|
|
|
|
_auto = False
|
2010-03-03 07:14:05 +00:00
|
|
|
_inherit = "report.crm.case"
|
2010-02-23 11:42:49 +00:00
|
|
|
_columns = {
|
2010-01-20 08:41:20 +00:00
|
|
|
'delay_close': fields.char('Delay to close', size=20, readonly=True),
|
2010-03-03 07:14:05 +00:00
|
|
|
'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.phonecall')]"),
|
2010-03-05 08:19:49 +00:00
|
|
|
|
2010-01-20 08:41:20 +00:00
|
|
|
}
|
|
|
|
def init(self, cr):
|
2010-03-03 07:14:05 +00:00
|
|
|
tools.drop_view_if_exists(cr, 'report_crm_phonecall')
|
2010-01-20 08:41:20 +00:00
|
|
|
cr.execute("""
|
2010-03-03 07:14:05 +00:00
|
|
|
create or replace view report_crm_phonecall as (
|
2010-01-20 08:41:20 +00:00
|
|
|
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.categ_id,
|
2010-03-05 08:19:49 +00:00
|
|
|
c.partner_id,
|
2010-03-03 08:54:24 +00:00
|
|
|
count(*) as nbr,
|
2010-01-20 08:41:20 +00:00
|
|
|
0 as avg_answers,
|
|
|
|
0.0 as perc_done,
|
2010-03-03 08:54:24 +00:00
|
|
|
0.0 as perc_cancel,
|
2010-01-20 08:41:20 +00:00
|
|
|
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
|
|
|
|
from
|
|
|
|
crm_phonecall c
|
2010-03-05 08:19:49 +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.categ_id,c.partner_id
|
2010-01-20 08:41:20 +00:00
|
|
|
)""")
|
2010-03-03 08:54:24 +00:00
|
|
|
report_crm_phonecall()
|
2010-02-23 11:42:49 +00:00
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|