[IMP]report_crm: Add the group by and modify the view

bzr revid: sbh@tinyerp.com-20100302134750-yk4ht64xoaca2d6t
This commit is contained in:
sbh (Open ERP) 2010-03-02 19:17:50 +05:30
parent b6e07076ea
commit 34ac80b482
4 changed files with 287 additions and 275 deletions

View File

@ -30,7 +30,7 @@
'website': 'http://www.openerp.com',
'depends': ['crm'],
'init_xml': [],
'update_xml': ['security/ir.model.access.csv',
'update_xml': [#'security/ir.model.access.csv',
'report_crm_view.xml',
'report_crm_lead_view.xml',
'report_crm_claim_view.xml',

View File

@ -1,273 +1,267 @@
from osv import fields,osv
import tools
class report_crm_lead_user(osv.osv):
_name = "report.crm.lead.user"
class report_crm_lead(osv.osv):
_name = "report.crm.lead"
_description = "Leads by user and section"
_auto = False
_inherit = "report.crm.case.user"
_columns = {
'probability': fields.float('Avg. Probability', readonly=True),
'amount_revenue': fields.float('Est.Revenue', readonly=True),
'amount_costs': fields.float('Est.Cost', readonly=True),
'amount_revenue_prob': fields.float('Est. Rev*Prob.', readonly=True),
'delay_close': fields.char('Delay to close', size=20, readonly=True),
}
def init(self, cr):
tools.drop_view_if_exists(cr, 'report_crm_lead_user')
cr.execute("""
create or replace view report_crm_lead_user 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,
count(*) as nbr,
sum(planned_revenue) as amount_revenue,
sum(planned_cost) as amount_costs,
sum(planned_revenue*probability)::decimal(16,2) as amount_revenue_prob,
avg(probability)::decimal(16,2) as probability,
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_lead c
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.state, c.user_id,c.section_id
)""")
report_crm_lead_user()
class report_crm_lead_categ(osv.osv):
_name = "report.crm.lead.categ"
_description = "Leads by section and category"
_auto = False
_inherit = "report.crm.case.categ"
_columns = {
'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]"),
'amount_revenue': fields.float('Est.Revenue', readonly=True),
'amount_costs': fields.float('Est.Cost', readonly=True),
'amount_revenue_prob': fields.float('Est. Rev*Prob.', readonly=True),
'probability': fields.float('Avg. Probability', readonly=True),
'delay_close': fields.char('Delay Close', size=20, readonly=True),
}
def init(self, cr):
tools.drop_view_if_exists(cr, 'report_crm_lead_categ')
cr.execute("""
create or replace view report_crm_lead_categ as (
select
min(c.id) as id,
to_char(c.create_date, 'YYYY') as name,
to_char(c.create_date, 'MM') as month,
c.categ_id,
c.state,
c.section_id,
count(*) as nbr,
sum(planned_revenue) as amount_revenue,
sum(planned_cost) as amount_costs,
sum(planned_revenue*probability)::decimal(16,2) as amount_revenue_prob,
avg(probability)::decimal(16,2) as probability,
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_lead c
group by c.categ_id,to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.state,c.section_id
)""")
report_crm_lead_categ()
class report_crm_lead_section(osv.osv):
_name = "report.crm.lead.section"
_description = "Leads by Section"
_auto = False
_inherit = "report.crm.case.section"
def _get_data(self, cr, uid, ids, field_name, arg, context={}):
res = {}
state_perc = 0.0
avg_ans = 0.0
for case in self.browse(cr, uid, ids, context):
if field_name != 'avg_answers':
state = field_name[5:]
cr.execute("select count(*) from crm_lead where section_id =%s and state='%s'"%(case.section_id.id,state))
state_cases = cr.fetchone()[0]
perc_state = (state_cases / float(case.nbr_cases) ) * 100
res[case.id] = perc_state
else:
cr.execute('select count(*) from crm_case_log l where l.section_id=%s'%(case.section_id.id))
logs = cr.fetchone()[0]
avg_ans = logs / case.nbr_cases
res[case.id] = avg_ans
return res
_columns = {
'avg_answers': fields.function(_get_data,string='Avg. Answers', method=True,type="integer"),
'perc_done': fields.function(_get_data,string='%Done', method=True,type="float"),
'perc_cancel': fields.function(_get_data,string='%Cancel', method=True,type="float"),
'delay_close': fields.char('Delay to close', size=20, readonly=True),
}
_order = 'name desc, section_id'
def init(self, cr):
tools.drop_view_if_exists(cr, 'report_crm_lead_section')
cr.execute("""
create or replace view report_crm_lead_section as (
select
min(c.id) as id,
to_char(c.create_date, 'YYYY') as name,
to_char(c.create_date, 'MM') as month,
count(*) as nbr_cases,
c.section_id as section_id,
0 as avg_answers,
0.0 as perc_done,
0.0 as perc_cancel,
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_lead c
group by to_char(c.create_date, 'YYYY'),to_char(c.create_date, 'MM'),c.section_id
)""")
report_crm_lead_section()
class report_crm_lead_section_stage(osv.osv):
_name = "report.crm.lead.section.stage"
_description = "Leads by section and stage"
_auto = False
_inherit = "report.crm.case.section.stage"
_columns = {
'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
'amount_revenue': fields.float('Est.Revenue', readonly=True),
'delay_close': fields.char('Delay Close', size=20, readonly=True),
}
_order = 'stage_id, section_id'
def init(self, cr):
tools.sql.drop_view_if_exists(cr, "report_crm_lead_section_stage")
cr.execute("""
create view report_crm_lead_section_stage as (
select
min(c.id) as id,
to_char(c.create_date,'YYYY') as name,
to_char(c.create_date, 'MM') as month,
c.user_id,
c.state,
c.stage_id,
c.section_id,
c.categ_id,
count(*) as nbr,
sum(planned_revenue) as amount_revenue,
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_lead c
where c.stage_id is not null
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.user_id, c.state, c.stage_id, c.categ_id, c.section_id)""")
report_crm_lead_section_stage()
class report_crm_lead_section_type(osv.osv):
_name = "report.crm.lead.section.type"
_inherit = "report.crm.case.section.type"
_description = "Leads by section and type"
_auto = False
_columns = {
'type_id': fields.many2one('crm.case.resource.type', 'Lead Type', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
'amount_revenue': fields.float('Est.Revenue', readonly=True),
'delay_close': fields.char('Delay Close', size=20, readonly=True),
}
_order = 'type_id'
def init(self, cr):
tools.sql.drop_view_if_exists(cr, "report_crm_lead_section_type")
tools.drop_view_if_exists(cr, 'report_crm_lead')
cr.execute("""
create view report_crm_lead_section_type as (
select
min(c.id) as id,
to_char(c.create_date,'YYYY') as name,
to_char(c.create_date, 'MM') as month,
c.user_id,
c.state,
c.type_id,
c.stage_id,
c.section_id,
count(*) as nbr,
sum(planned_revenue) as amount_revenue,
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_lead c
where c.type_id is not null
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.user_id, c.state, c.stage_id, c.type_id, c.section_id)""")
report_crm_lead_section_type()
class report_crm_lead_section_categ_stage(osv.osv):
_name = "report.crm.lead.section.categ.stage"
_inherit = "report.crm.case.section.categ.stage"
_description = "Leads by Section, Category and Stage"
_auto = False
_columns = {
'categ_id': fields.many2one('crm.case.categ','Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
'stage_id':fields.many2one('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
'delay_close': fields.char('Delay Close', size=20, readonly=True),
}
_order = 'stage_id, categ_id'
def init(self, cr):
tools.sql.drop_view_if_exists(cr, "report_crm_lead_section_categ_stage")
cr.execute("""
create view report_crm_lead_section_categ_stage as (
select
min(c.id) as id,
to_char(c.create_date,'YYYY') as name,
to_char(c.create_date, 'MM') as month,
c.user_id,
c.categ_id,
c.state,
c.stage_id,
c.section_id,
count(*) as nbr,
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_lead c
where c.categ_id is not null AND c.stage_id is not null
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'),c.user_id, c.categ_id, c.state, c.stage_id, c.section_id)""")
report_crm_lead_section_categ_stage()
class report_crm_lead_section_categ_type(osv.osv):
_name = "report.crm.lead.section.categ.type"
_inherit = "report.crm.case.section.categ.type"
_description = "Leads by Section, Category and Type"
_auto = False
_columns = {
'categ_id':fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
'type_id': fields.many2one('crm.case.resource.type', 'Lead Type', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
'stage_id':fields.many2one('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
'delay_close': fields.char('Delay Close', size=20, readonly=True),
}
_order = 'categ_id, type_id'
def init(self, cr):
tools.sql.drop_view_if_exists(cr, "report_crm_lead_section_categ_type")
cr.execute("""
create view report_crm_lead_section_categ_type as (
create or replace view report_crm_lead as (
select
min(c.id) as id,
to_char(c.create_date, 'YYYY') as name,
to_char(c.create_date, 'MM') as month,
c.user_id,
c.categ_id,
c.type_id,
c.state,
c.user_id,
c.stage_id,
c.section_id,
count(*) as nbr,
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_lead c
where c.categ_id is not null AND c.type_id is not null
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'),c.user_id, c.categ_id, c.type_id, c.state, c.stage_id, c.section_id)""")
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.state, c.user_id,c.section_id,c.stage_id
)""")
report_crm_lead()
report_crm_lead_section_categ_type()
#class report_crm_lead_categ(osv.osv):
# _name = "report.crm.lead.categ"
# _description = "Leads by section and category"
# _auto = False
# _inherit = "report.crm.case.categ"
# _columns = {
# 'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]"),
# 'amount_revenue': fields.float('Est.Revenue', readonly=True),
# 'amount_costs': fields.float('Est.Cost', readonly=True),
# 'amount_revenue_prob': fields.float('Est. Rev*Prob.', readonly=True),
# 'probability': fields.float('Avg. Probability', readonly=True),
# 'delay_close': fields.char('Delay Close', size=20, readonly=True),
# }
#
# def init(self, cr):
# tools.drop_view_if_exists(cr, 'report_crm_lead_categ')
# cr.execute("""
# create or replace view report_crm_lead_categ as (
# select
# min(c.id) as id,
# to_char(c.create_date, 'YYYY') as name,
# to_char(c.create_date, 'MM') as month,
# c.categ_id,
# c.state,
# c.section_id,
# count(*) as nbr,
# sum(planned_revenue) as amount_revenue,
# sum(planned_cost) as amount_costs,
# sum(planned_revenue*probability)::decimal(16,2) as amount_revenue_prob,
# avg(probability)::decimal(16,2) as probability,
# to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
# from
# crm_lead c
# group by c.categ_id,to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.state,c.section_id
# )""")
#report_crm_lead_categ()
#
#class report_crm_lead_section(osv.osv):
# _name = "report.crm.lead.section"
# _description = "Leads by Section"
# _auto = False
# _inherit = "report.crm.case.section"
#
# def _get_data(self, cr, uid, ids, field_name, arg, context={}):
# res = {}
# state_perc = 0.0
# avg_ans = 0.0
#
# for case in self.browse(cr, uid, ids, context):
# if field_name != 'avg_answers':
# state = field_name[5:]
# cr.execute("select count(*) from crm_lead where section_id =%s and state='%s'"%(case.section_id.id,state))
# state_cases = cr.fetchone()[0]
# perc_state = (state_cases / float(case.nbr_cases) ) * 100
#
# res[case.id] = perc_state
# else:
# cr.execute('select count(*) from crm_case_log l where l.section_id=%s'%(case.section_id.id))
# logs = cr.fetchone()[0]
#
# avg_ans = logs / case.nbr_cases
# res[case.id] = avg_ans
#
# return res
#
# _columns = {
# 'avg_answers': fields.function(_get_data,string='Avg. Answers', method=True,type="integer"),
# 'perc_done': fields.function(_get_data,string='%Done', method=True,type="float"),
# 'perc_cancel': fields.function(_get_data,string='%Cancel', method=True,type="float"),
# 'delay_close': fields.char('Delay to close', size=20, readonly=True),
# }
# _order = 'name desc, section_id'
# def init(self, cr):
# tools.drop_view_if_exists(cr, 'report_crm_lead_section')
# cr.execute("""
# create or replace view report_crm_lead_section as (
# select
# min(c.id) as id,
# to_char(c.create_date, 'YYYY') as name,
# to_char(c.create_date, 'MM') as month,
# count(*) as nbr_cases,
# c.section_id as section_id,
# 0 as avg_answers,
# 0.0 as perc_done,
# 0.0 as perc_cancel,
# to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
# from
# crm_lead c
# group by to_char(c.create_date, 'YYYY'),to_char(c.create_date, 'MM'),c.section_id
# )""")
#report_crm_lead_section()
#
#class report_crm_lead_section_stage(osv.osv):
# _name = "report.crm.lead.section.stage"
# _description = "Leads by section and stage"
# _auto = False
# _inherit = "report.crm.case.section.stage"
# _columns = {
# 'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
# 'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
# 'amount_revenue': fields.float('Est.Revenue', readonly=True),
# 'delay_close': fields.char('Delay Close', size=20, readonly=True),
# }
# _order = 'stage_id, section_id'
#
# def init(self, cr):
# tools.sql.drop_view_if_exists(cr, "report_crm_lead_section_stage")
# cr.execute("""
# create view report_crm_lead_section_stage as (
# select
# min(c.id) as id,
# to_char(c.create_date,'YYYY') as name,
# to_char(c.create_date, 'MM') as month,
# c.user_id,
# c.state,
# c.stage_id,
# c.section_id,
# c.categ_id,
# count(*) as nbr,
# sum(planned_revenue) as amount_revenue,
# to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
# from
# crm_lead c
# where c.stage_id is not null
# group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.user_id, c.state, c.stage_id, c.categ_id, c.section_id)""")
#
#report_crm_lead_section_stage()
#
#class report_crm_lead_section_type(osv.osv):
# _name = "report.crm.lead.section.type"
# _inherit = "report.crm.case.section.type"
# _description = "Leads by section and type"
# _auto = False
# _columns = {
# 'type_id': fields.many2one('crm.case.resource.type', 'Lead Type', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
# 'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
# 'amount_revenue': fields.float('Est.Revenue', readonly=True),
# 'delay_close': fields.char('Delay Close', size=20, readonly=True),
# }
# _order = 'type_id'
#
# def init(self, cr):
# tools.sql.drop_view_if_exists(cr, "report_crm_lead_section_type")
# cr.execute("""
# create view report_crm_lead_section_type as (
# select
# min(c.id) as id,
# to_char(c.create_date,'YYYY') as name,
# to_char(c.create_date, 'MM') as month,
# c.user_id,
# c.state,
# c.type_id,
# c.stage_id,
# c.section_id,
# count(*) as nbr,
# sum(planned_revenue) as amount_revenue,
# to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
# from
# crm_lead c
# where c.type_id is not null
# group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.user_id, c.state, c.stage_id, c.type_id, c.section_id)""")
#
#report_crm_lead_section_type()
#
#class report_crm_lead_section_categ_stage(osv.osv):
# _name = "report.crm.lead.section.categ.stage"
# _inherit = "report.crm.case.section.categ.stage"
# _description = "Leads by Section, Category and Stage"
# _auto = False
# _columns = {
# 'categ_id': fields.many2one('crm.case.categ','Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
# 'stage_id':fields.many2one('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
# 'delay_close': fields.char('Delay Close', size=20, readonly=True),
# }
# _order = 'stage_id, categ_id'
#
# def init(self, cr):
# tools.sql.drop_view_if_exists(cr, "report_crm_lead_section_categ_stage")
# cr.execute("""
# create view report_crm_lead_section_categ_stage as (
# select
# min(c.id) as id,
# to_char(c.create_date,'YYYY') as name,
# to_char(c.create_date, 'MM') as month,
# c.user_id,
# c.categ_id,
# c.state,
# c.stage_id,
# c.section_id,
# count(*) as nbr,
# to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
# from
# crm_lead c
# where c.categ_id is not null AND c.stage_id is not null
# group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'),c.user_id, c.categ_id, c.state, c.stage_id, c.section_id)""")
#
#report_crm_lead_section_categ_stage()
#
#class report_crm_lead_section_categ_type(osv.osv):
# _name = "report.crm.lead.section.categ.type"
# _inherit = "report.crm.case.section.categ.type"
# _description = "Leads by Section, Category and Type"
# _auto = False
# _columns = {
# 'categ_id':fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
# 'type_id': fields.many2one('crm.case.resource.type', 'Lead Type', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
# 'stage_id':fields.many2one('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
# 'delay_close': fields.char('Delay Close', size=20, readonly=True),
# }
# _order = 'categ_id, type_id'
#
# def init(self, cr):
# tools.sql.drop_view_if_exists(cr, "report_crm_lead_section_categ_type")
# cr.execute("""
# create view report_crm_lead_section_categ_type as (
# select
# min(c.id) as id,
# to_char(c.create_date, 'YYYY') as name,
# to_char(c.create_date, 'MM') as month,
# c.user_id,
# c.categ_id,
# c.type_id,
# c.state,
# c.stage_id,
# c.section_id,
# count(*) as nbr,
# to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
# from
# crm_lead c
# where c.categ_id is not null AND c.type_id is not null
# group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'),c.user_id, c.categ_id, c.type_id, c.state, c.stage_id, c.section_id)""")
#
#report_crm_lead_section_categ_type()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -6,39 +6,34 @@
-->
<record id="view_crm_lead_user_tree" model="ir.ui.view">
<field name="name">report.crm.lead.user.tree</field>
<field name="model">report.crm.lead.user</field>
<field name="inherit_id" ref="view_crm_case_user_tree"/>
<field name="name">report.crm.lead.tree</field>
<field name="model">report.crm.lead</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<field name="nbr" position="after">
<field name="delay_close"/>
<field name="amount_revenue"/>
<field name="amount_costs"/>
<field name="amount_revenue_prob"/>
<field name="probability"/>
</field>
<tree string="Leads">
<field name="name" />
<field name="month"/>
<field name="nbr" />
<field name="delay_close"/>
</tree>
</field>
</record>
<record id="view_crm_lead_user_form" model="ir.ui.view">
<field name="name">report.crm.lead.user.form</field>
<field name="model">report.crm.lead.user</field>
<field name="model">report.crm.lead</field>
<field name="inherit_id" ref="view_crm_case_user_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="nbr" position="after">
<field name="delay_close"/>
<field name="amount_revenue"/>
<field name="amount_costs"/>
<field name="amount_revenue_prob"/>
<field name="probability"/>
<field name="stage_id"/>
</field>
</field>
</record>
<record id="view_crm_lead_user_graph" model="ir.ui.view">
<field name="name">report.crm.lead.user.graph</field>
<field name="model">report.crm.lead.user</field>
<field name="model">report.crm.lead</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph orientation="horizontal" string="Leads by User and Section" type="bar">
@ -51,27 +46,38 @@
<record id="view_crm_lead_user_filter" model="ir.ui.view">
<field name="name">report.crm.lead.user.select</field>
<field name="model">report.crm.lead.user</field>
<field name="model">report.crm.lead</field>
<field name="inherit_id" ref="view_crm_case_user_filter"/>
<field name="type">search</field>
<field name="arch" type="xml">
<field name="state" position="before">
</field>
<search string="Search Cases by User">
<field name="state" position="before"/>
</search>
</field>
</record>
<record id="action_report_crm_lead_user_tree" model="ir.actions.act_window">
<field name="name">Leads by User and Section</field>
<field name="res_model">report.crm.lead.user</field>
<field name="res_model">report.crm.lead</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="view_mode">graph,tree,from</field>
<field name="view_id" ref="view_crm_lead_user_graph"/>
<field name="search_view_id" ref="view_crm_lead_user_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_report_crm_lead_tree1">
<field name="sequence" eval="2"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_crm_lead_user_tree"/>
<field name="act_window_id" ref="action_report_crm_lead_user_tree"/>
</record>
<menuitem name="Leads" id="menu_crm_leads_tree" parent="crm.next_id_52"/>
<menuitem action="action_report_crm_lead_user_tree" id="menu_crm_lead_user_tree" parent="menu_crm_leads_tree"/>
<!-- # Leads by section and category of case -->
<!--
# Leads by section and category of case
<record id="view_crm_lead_categ_tree" model="ir.ui.view">
<field name="name">report.crm.lead.categ.tree</field>
@ -138,7 +144,7 @@
</record>
<menuitem action="action_report_crm_lead_categ_tree" id="menu_crm_lead_categ_tree" parent="menu_crm_leads_tree"/>
<!-- Leads by Section -->
Leads by Section
<record id="view_report_crm_lead_section_tree" model="ir.ui.view">
<field name="name">report.crm.lead.section.tree</field>
@ -189,7 +195,7 @@
<menuitem action="action_report_crm_lead_section_tree" id="menu_crm_lead_section_tree" parent="menu_crm_leads_tree"/>
<!-- Cases by section and stage -->
Cases by section and stage
<record model="ir.ui.view" id="view_crm_lead_section_stage_tree">
<field name="name">Leads Report - Sections and Stage(Tree)</field>
<field name="model">report.crm.lead.section.stage</field>
@ -481,5 +487,6 @@
<field name="act_window_id" ref="action_report_crm_lead_section_categ_type_tree"/>
</record>
<menuitem action="action_report_crm_lead_section_categ_type_tree" id="menu_crm_lead_section_categ_type_tree" parent="menu_crm_leads_tree"/>
-->
</data>
</openerp>

View File

@ -56,11 +56,13 @@
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Search Cases by User">
<group col="12" colspan="4">
<group col="16" colspan="8">
<filter string="My Cases" icon="terp-hr" domain="[('user_id','=',uid)]" help="My cases by section"/>
<separator orientation="vertical"/>
<filter string="This Year" icon="terp-hr" domain="[('name','=',time.localtime()[0])]"/>
<filter string="This Month" icon="terp-hr" domain="[('month','=',time.strftime('%%m'))]"/>
<filter string="Won" icon="terp-hr" domain="[('state','=','done')]"/>
<filter string="Lost" icon="terp-hr" domain="[('state','=','cancel')]"/>
<separator orientation="vertical"/>
<field name="name" select="1"/>
<field name="month" select="1"/>
@ -69,6 +71,15 @@
<field name="nbr" select="1"/>
<field name="state" select="1"/>
</group>
<group expand="1" string="Group By..." colspan="4" col="8">
<filter string="User" icon="terp-sale" domain="[]" context="{'group_by':'user_id'}"/>
<filter string="Section" icon="terp-sale" domain="[]" context="{'group_by':'section_id'}"/>
<filter string="State" icon="terp-sale" domain="[]" context="{'group_by':'state'}"/>
<filter string="Stage" icon="terp-sale" domain="[]" context="{'group_by':'stage_id'}"/>
<filter string="Month" icon="terp-sale" domain="[]" context="{'group_by':'month'}"/>
</group>
</search>
</field>
</record>