[MERGE]
authorHarry (Open ERP) <hmo@tinyerp.com>
Wed, 3 Mar 2010 08:54:24 +0000 (14:24 +0530)
committerHarry (Open ERP) <hmo@tinyerp.com>
Wed, 3 Mar 2010 08:54:24 +0000 (14:24 +0530)
bzr revid: hmo@tinyerp.com-20100303085424-wunax0ibvnw3ni4v

12 files changed:
1  2 
addons/report_crm/__terp__.py
addons/report_crm/report_crm.py
addons/report_crm/report_crm_claim_view.xml
addons/report_crm/report_crm_fundraising.py
addons/report_crm/report_crm_fundraising_view.xml
addons/report_crm/report_crm_lead.py
addons/report_crm/report_crm_lead_view.xml
addons/report_crm/report_crm_opportunity.py
addons/report_crm/report_crm_opportunity_view.xml
addons/report_crm/report_crm_phonecall.py
addons/report_crm/report_crm_phonecall_view.xml
addons/report_crm/report_crm_view.xml

@@@ -24,8 -24,8 +24,8 @@@
      'name': 'CRM Management - Reporting',
      'version': '1.0',
      'category': 'Generic Modules/CRM & SRM',
--    'description': """A module that adds new reports based on CRM cases.
--    Case By section, Case By category""",
++    'description': """A module that adds new reports based on Leads, Opportunities, Phonecalls, Claims, FunRising.
++    """,
      'author': 'Tiny',
      'website': 'http://www.openerp.com',
      'depends': ['crm'],
@@@ -30,16 -30,16 +30,48 @@@ AVAILABLE_STATES = 
      ('pending','Pending')
  ]
  
- class report_crm_case_user(osv.osv):
-     _name = "report.crm.case.user"
-     _description = "Cases by user and section"
+ class report_crm_case(osv.osv):
+     _name = "report.crm.case"
+     _description = "Cases and section"
      _auto = False
++
++    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_opportunity 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:
++                model_name = self._name.split('report.')
++                if len(model_name) < 2:
++                    res[case.id] = 0.0
++                else:
++                    model_name = model_name[1]
++
++                    cr.execute("select count(*) from crm_case_log l, ir_model m  where l.model_id=m.id and m.model = '%s'" , model_name)
++                    logs = cr.fetchone()[0]
++                    
++                    avg_ans = logs / case.nbr_cases
++                    res[case.id] = avg_ans       
++        
++        return res
++
      _columns = {
          '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, 'Status', size=16, readonly=True),
++        '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"),
          '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),
      }
                      crm_case 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_case_user()
- class report_crm_case_categ(osv.osv):
-     _name = "report.crm.case.categ"
-     _description = "Cases by section and category"
-     _auto = False
-     _columns = {
-         'name': fields.char('Year',size=64,required=False, readonly=True),
-         'section_id':fields.many2one('crm.case.section', 'Section', readonly=True),
-         'nbr': fields.integer('# of Cases', readonly=True),
-         'state': fields.selection(AVAILABLE_STATES, 'Status', 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),
-     }
-     _order = 'name desc'
-     def init(self, cr):
-         tools.drop_view_if_exists(cr, 'report_crm_case_categ')
-         cr.execute("""
-             create or replace view report_crm_case_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.state,
-                     c.section_id,
-                     count(*) as nbr
-                 from
-                     crm_case c
-                 group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.state,c.section_id
-             )""")
- report_crm_case_categ()
- class report_crm_case_section(osv.osv):
-     _name = "report.crm.case.section"
-     _description = "Cases by Section"
-     _auto = False
-     
-     _columns = {
-         '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_cases': fields.integer('# of Cases', 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),
-     }
-     _order = 'name desc'
-     def init(self, cr):
-         tools.drop_view_if_exists(cr, 'report_crm_case_section')
-         cr.execute("""
-             create or replace view report_crm_case_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
-                 from
-                     crm_case c
-                 group by to_char(c.create_date, 'YYYY'),to_char(c.create_date, 'MM'), c.section_id
-             )""")
- report_crm_case_section()
+ report_crm_case()
  
 -
 -class report_crm_case_section(osv.osv):
 -    _name = "report.crm.case.section"
 -    _description = "Cases by Section"
 -    _auto = False
 -    
 -    _columns = {
 -        '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_cases': fields.integer('# of Cases', 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),
 -    }
 -    _order = 'name desc'
 -    def init(self, cr):
 -        tools.drop_view_if_exists(cr, 'report_crm_case_section')
 -        cr.execute("""
 -            create or replace view report_crm_case_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
 -                from
 -                    crm_case c
 -                group by to_char(c.create_date, 'YYYY'),to_char(c.create_date, 'MM'), c.section_id
 -            )""")
 -report_crm_case_section()
 -
 -
 -
  class report_crm_case_service_dashboard(osv.osv):
      _name = "report.crm.case.service.dashboard"
      _description = "Report of Closed and Open CRM Cases within past 15 days"
@@@ -1,16 -1,16 +1,13 @@@
  <?xml version="1.0" encoding="utf-8"?>
  <openerp>
--    <data>
--      <!--
--      Claim by user and section
--      -->
++    <data>    
  
          <record id="view_report_crm_claim_tree" model="ir.ui.view">
              <field name="name">report.crm.claim.tree</field>
              <field name="model">report.crm.claim</field>
              <field name="type">tree</field>
              <field name="arch" type="xml">
--               <tree string="Leads">
++               <tree string="Claims">
                        <field name="name" />
                                        <field name="month"/>
                        <field name="nbr" string="#Claim"/>
@@@ -63,8 -63,9 +60,9 @@@
              </field>
          </record>
          
-         <record id="action_report_crm_claim_tree" model="ir.actions.act_window">
-             <field name="name">Claim</field>
 -        <record id="action_report_crm_claim_tree" model="ir.actions.act_window">
 -            <field name="name">Claim</field>
++        <record id="action_report_crm_claim" model="ir.actions.act_window">
++            <field name="name">Claims</field>
              <field name="res_model">report.crm.claim</field>
              <field name="view_type">form</field>
                        <field name="view_mode">graph,tree</field>
                <field name="sequence" eval="2"/>
                <field name="view_mode">tree</field>
                <field name="view_id" ref="view_report_crm_claim_tree"/>
-               <field name="act_window_id" ref="action_report_crm_claim_tree"/>
+               <field name="act_window_id" ref="action_report_crm_claim"/>
+           </record>        
+                               
+               <record model="ir.actions.act_window.view" id="action_report_crm_claim_graph">
 -              <field name="sequence" eval="2"/>
++              <field name="sequence" eval="1"/>
+               <field name="view_mode">graph</field>
+               <field name="view_id" ref="view_crm_claim_graph"/>
+               <field name="act_window_id" ref="action_report_crm_claim"/>
            </record>        
        
          
-         <menuitem name="Claim" id="menu_crm_claim_tree" action="action_report_crm_claim_tree" parent="crm.next_id_52"/>       
 -        <menuitem name="Claim" id="menu_crm_claim_tree" parent="crm.next_id_52"/>
 -        <menuitem action="action_report_crm_claim" id="menu_crm_claim_user_tree" parent="menu_crm_claim_tree"/>
++        <menuitem name="Claim" id="menu_crm_claim_tree" action="action_report_crm_claim" parent="crm.next_id_52"/>       
  
    </data>
  </openerp>
@@@ -1,12 -1,14 +1,13 @@@
  from osv import fields,osv
  import tools
  
- class report_crm_fundraising_user(osv.osv):
-     _name = "report.crm.fundraising.user"
-     _description = "Fundraising by user and section"
+ class report_crm_fundraising(osv.osv):
+     _name = "report.crm.fundraising"
 -    _description = "Fundraising by user and section"
      _auto = False
-     _inherit = "report.crm.case.user"
+     _inherit = "report.crm.case"
      _columns = {
+         'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]"),
+         'stage_id':fields.many2one('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]", readonly=True),
          'probability': fields.float('Avg. Probability', readonly=True),
          'amount_revenue': fields.float('Est.Revenue', readonly=True),
          'amount_costs': fields.float('Est.Cost', readonly=True),
                      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_fundraising 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_fundraising_user()
- class report_crm_fundraising_categ(osv.osv):
-     _name = "report.crm.fundraising.categ"
-     _description = "Fundraising 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.fundraising')]"),
-         '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_fundraising_categ')
-         cr.execute("""
-             create or replace view report_crm_fundraising_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,
+                     c.stage_id,
                      count(*) as nbr,
++                    0 as avg_answers,
++                    0.0 as perc_done,
++                    0.0 as perc_cancel,
                      sum(planned_revenue) as amount_revenue,
                      sum(planned_cost) as amount_costs,
                      sum(planned_revenue*probability)::decimal(16,2) as amount_revenue_prob,
                      to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
                  from
                      crm_fundraising c
-                 group by c.categ_id,to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.state,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.categ_id,c.stage_id
              )""")
- report_crm_fundraising_categ()
- class report_crm_fundraising_section(osv.osv):
-     _name = "report.crm.fundraising.section"
-     _description = "Fundraising 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_fundraising 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_fundraising_section')
-         cr.execute("""
-             create or replace view report_crm_fundraising_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_fundraising c
-                 group by to_char(c.create_date, 'YYYY'),to_char(c.create_date, 'MM'),c.section_id
-             )""")
- report_crm_fundraising_section()
- class report_crm_fundraising_section_type(osv.osv):
-     _name = "report.crm.fundraising.section.type"
-     _inherit = "report.crm.case.section.type"
-     _description = "Fundraising by section and type"
-     _auto = False
-     _columns = {
-         'type_id': fields.many2one('crm.case.resource.type', 'Fundraising Type', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.fundraising')]", readonly=True),
-         'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.fundraising')]", 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_fundraising_section_type")
-         cr.execute("""
-               create view report_crm_fundraising_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_fundraising 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_fundraising_section_type()
- class report_crm_fundraising_section_categ_stage(osv.osv):
-     _name = "report.crm.fundraising.section.categ.stage"
-     _inherit = "report.crm.case.section.categ.stage"
-     _description = "Fundraising 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.fundraising')]", readonly=True),
-         'stage_id':fields.many2one('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.fundraising')]", 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_fundraising_section_categ_stage")
-         cr.execute("""
-               create view report_crm_fundraising_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_fundraising 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_fundraising_section_categ_stage()
- class report_crm_fundraising_section_categ_type(osv.osv):
-     _name = "report.crm.fundraising.section.categ.type"
-     _inherit = "report.crm.case.section.categ.type"
-     _description = "Fundraising 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.fundraising')]", readonly=True),
-         'type_id': fields.many2one('crm.case.resource.type', 'Fundraising Type', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.fundraising')]", readonly=True),
-         'stage_id':fields.many2one('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.fundraising')]", 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_fundraising_section_categ_type")
-         cr.execute("""
-               create view report_crm_fundraising_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_fundraising 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_fundraising_section_categ_type()
- # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+ report_crm_fundraising()
 -
 -
 -class report_crm_fundraising_section(osv.osv):
 -    _name = "report.crm.fundraising.section"
 -    _description = "Fundraising 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_fundraising 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_fundraising_section')
 -        cr.execute("""
 -            create or replace view report_crm_fundraising_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_fundraising c
 -                group by to_char(c.create_date, 'YYYY'),to_char(c.create_date, 'MM'),c.section_id
 -            )""")
 -report_crm_fundraising_section()
 -
 -
 -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
++# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
              </field>
          </record>
          
-         <record id="view_crm_fundraising_user_graph" model="ir.ui.view">
-             <field name="name">report.crm.fundraising.user.graph</field>
-             <field name="model">report.crm.fundraising.user</field>
+         <record id="view_crm_fundraising_graph" model="ir.ui.view">
+             <field name="name">report.crm.fundraising.graph</field>
+             <field name="model">report.crm.fundraising</field>
              <field name="type">graph</field>
              <field name="arch" type="xml">
-                 <graph orientation="horizontal" string="fundraising by User and Section" type="bar">
 -                <graph orientation="horizontal" string="Fundraising by User and Section" type="bar">
++                <graph orientation="horizontal" string="Fundraising" type="bar">
                      <field name="state"/>
                      <field name="nbr" operator="+"/>
                      <field group="True" name="user_id"/>
              </field>
          </record>
          
-         <record id="action_report_crm_fundraising_user_tree" model="ir.actions.act_window">
-             <field name="name">Fundraising by User and Section</field>
-             <field name="res_model">report.crm.fundraising.user</field>
-             <field name="view_type">form</field>
-             <field name="view_mode">graph,tree</field>
-             <field name="view_id" ref="view_crm_fundraising_user_graph"/>
-             <field name="search_view_id" ref="view_crm_fundraising_user_filter"/>
-         </record>
-         <menuitem name="Fundraising" id="menu_crm_fundraising_tree" parent="crm.next_id_52"/>
-         <menuitem action="action_report_crm_fundraising_user_tree" id="menu_crm_fundraising_user_tree" parent="menu_crm_fundraising_tree"/>
-         
-         <!-- # Fundraising by section and category of case -->
-         <record id="view_crm_fundraising_categ_tree" model="ir.ui.view">
-             <field name="name">report.crm.fundraising.categ.tree</field>
-             <field name="model">report.crm.fundraising.categ</field>
-             <field name="inherit_id" ref="view_crm_case_categ_tree"/>
-             <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>
-             </field>
-         </record>
-         <record id="view_crm_fundraising_categ_form" model="ir.ui.view">
-             <field name="name">report.crm.fundraising.categ.form</field>
-             <field name="model">report.crm.fundraising.categ</field>
-             <field name="inherit_id" ref="view_crm_case_categ_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>
-             </field>
-         </record>
-               <record id="view_crm_fundraising_categ_graph" model="ir.ui.view">
-             <field name="name">report.crm.fundraising.categ.graph</field>
-             <field name="model">report.crm.fundraising.categ</field>
-             <field name="type">graph</field>
-             <field name="arch" type="xml">
-                 <graph orientation="horizontal" string="fundraising by Section and Categories" type="bar">
-                     <field name="state"/>
-                     <field name="nbr" operator="+"/>
-                     <field group="True" name="categ_id"/>
-                 </graph>
-             </field>
-         </record>
-               <record id="view_crm_fundraising_categ_filter" model="ir.ui.view">
-             <field name="name">report.crm.fundraising.categ.select</field>
-             <field name="model">report.crm.fundraising.categ</field>
-                       <field name="inherit_id" ref="view_crm_case_categ_filter"/>
-             <field name="type">search</field>
-             <field name="arch" type="xml">
-                 <field name="state" position="before">
-                 </field>
-             </field>
-         </record>
-         <record id="action_report_crm_fundraising_categ_tree" model="ir.actions.act_window">
-             <field name="name">Fundraising by Categories and Section</field>
-             <field name="res_model">report.crm.fundraising.categ</field>
-             <field name="view_type">form</field>
-             <field name="view_mode">graph,tree</field>
-             <field name="view_id" ref="view_crm_fundraising_categ_graph"/>
-             <field name="search_view_id" ref="view_crm_fundraising_categ_filter"/>
-         </record>
-         <menuitem action="action_report_crm_fundraising_categ_tree" id="menu_crm_fundraising_categ_tree" parent="menu_crm_fundraising_tree"/>
-         
-         <!-- Fundraising by Section  -->
-         <record id="view_report_crm_fundraising_section_tree" model="ir.ui.view">
-             <field name="name">report.crm.fundraising.section.tree</field>
-             <field name="model">report.crm.fundraising.section</field>
-             <field name="inherit_id" ref="view_report_crm_case_section_tree"/>
-             <field name="type">tree</field>
-             <field name="arch" type="xml">
-                 <field name="nbr_cases" position="after">
-                       <field name="avg_answers"/>
-                       <field name="perc_done" select="2"/>
-                     <field name="perc_cancel" select="2"/>
-                     <field name="delay_close"/>
-                 </field>
-             </field>
-         </record>
-         <record id="view_report_crm_fundraising_section_graph" model="ir.ui.view">
-             <field name="name">report.crm.fundraising.section.graph</field>
-             <field name="model">report.crm.fundraising.section</field>
-             <field name="type">graph</field>
-             <field name="arch" type="xml">
-                 <graph orientation="horizontal" string="fundraising by Section" type="bar">
-                     <field name="name"/>
-                     <field name="nbr_cases" operator="+"/>
-                 </graph>
-             </field>
-         </record>
-               <record id="view_report_crm_fundraising_section_filter" model="ir.ui.view">
-             <field name="name">report.crm.fundraising.section.select</field>
-             <field name="model">report.crm.fundraising.section</field>
-             <field name="inherit_id" ref="view_report_crm_case_section_filter"/>
-             <field name="type">search</field>
-             <field name="arch" type="xml">
-                 <field name="nbr_cases" position="before">
-                 </field>
-             </field>
-         </record>
-         <record id="action_report_crm_fundraising_section_tree" model="ir.actions.act_window">
-             <field name="name">Fundraising by Section</field>
-             <field name="res_model">report.crm.fundraising.section</field>
+         <record id="action_report_crm_fundraising" model="ir.actions.act_window">
 -            <field name="name">Fundraising by User and Section</field>
++            <field name="name">Fundraising</field>
+             <field name="res_model">report.crm.fundraising</field>
              <field name="view_type">form</field>
              <field name="view_mode">graph,tree</field>
-             <field name="view_id" ref="view_report_crm_fundraising_section_graph"/>
-             <field name="search_view_id" ref="view_report_crm_fundraising_section_filter"/>
-         </record>
-         <menuitem action="action_report_crm_fundraising_section_tree" id="menu_crm_fundraising_section_tree" parent="menu_crm_fundraising_tree"/>
-               
-               #
-           # Fundraising by section and type
-           #
-           <record model="ir.ui.view" id="view_crm_fundraising_section_categ_tree">
-               <field name="name">CRM Report - Sections and Type(Tree)</field>
-               <field name="model">report.crm.fundraising.section.type</field>
-               <field name="inherit_id" ref="view_crm_case_section_categ_tree"/>
-               <field name="type">tree</field>
-               <field name="arch" type="xml">
-                   <field name="user_id" position="after">
-                       <field name="type_id"/>
-                       <field name="stage_id"/>
-                       <field name="amount_revenue"/>
-                       <field name="delay_close"/>
-                   </field>
-               </field>
-           </record>
-           <record model="ir.ui.view" id="view_crm_fundraising_section_categ_form">
-               <field name="name">CRM Report - Sections and Type(Form)</field>
-               <field name="model">report.crm.fundraising.section.type</field>
-               <field name="inherit_id" ref="view_crm_case_section_categ_form"/>
-               <field name="type">form</field>
-               <field name="arch" type="xml">
-                   <field name="user_id" position="after">
-                       <field name="type_id"/>
-                       <field name="stage_id"/>
-                       <field name="amount_revenue"/>
-                       <field name="delay_close"/>
-                   </field>
-               </field>
-           </record>
-           
-           <record model="ir.ui.view" id="view_crm_fundraising_section_categ_graph">
-               <field name="name">CRM Report - Sections and Type(Graph)</field>
-               <field name="model">report.crm.fundraising.section.type</field>
-               <field name="type">graph</field>
-               <field name="arch" type="xml">
-                   <graph string="Fundraising by Section and Type" type="bar" orientation="horizontal">
-                       <field name="type_id"/>
-                       <field name="amount_revenue" operator="+"/>
-                       <field name="section_id" group="True"/>
-                   </graph>
-               </field>
-           </record>
-           <record id="view_crm_fundraising_section_categ_filter" model="ir.ui.view">
-                   <field name="name">CRM Report - Sections and Type(Select)</field>
-                   <field name="model">report.crm.fundraising.section.type</field>
-                   <field name="inherit_id" ref="view_crm_case_section_categ_filter"/>
-                   <field name="type">search</field>
-                   <field name="arch" type="xml">
-                       <field name="section_id" position="after">
-                               <field name="type_id"/>
-                           </field>
-                   </field>
-               </record>
-       
-           <record model="ir.actions.act_window" id="action_report_crm_fundraising_section_categ_tree">
-               <field name="res_model">report.crm.fundraising.section.type</field>
-               <field name="name">Fundraising by section and type</field>
-               <field name="view_type">form</field>
-               <field name="view_mode">graph,tree</field>
-               <field name="search_view_id" ref="view_crm_fundraising_section_categ_filter"/>
-           </record>
-           <record model="ir.actions.act_window.view" id="action_crm_fundraising_section_categ_graph">
-               <field name="sequence" eval="1"/>
-               <field name="view_mode">graph</field>
-                       <field name="view_id" ref="view_crm_fundraising_section_categ_graph"/>
-                       <field name="act_window_id" ref="action_report_crm_fundraising_section_categ_tree"/>
-           </record>
-           <record model="ir.actions.act_window.view" id="action_crm_fundraising_section_categ_tree">
-              <field name="sequence" eval="2"/>
-              <field name="view_mode">tree</field>
-              <field name="view_id" ref="view_crm_fundraising_section_categ_tree"/>
-              <field name="act_window_id" ref="action_report_crm_fundraising_section_categ_tree"/>
-           </record>
-         <menuitem action="action_report_crm_fundraising_section_categ_tree" id="menu_crm_fundraising_section_categ_tree" parent="menu_crm_fundraising_tree"/>
-               
-               #
-           # Fundraising by section, category and stage
-           #
-           <record model="ir.ui.view" id="view_crm_fundraising_section_categ_stage_tree">
-               <field name="name">CRM Report - Section, Category and Stage(Tree)</field>
-               <field name="model">report.crm.fundraising.section.categ.stage</field>
-               <field name="inherit_id" ref="view_crm_case_section_categ_stage_tree"/>
-               <field name="type">tree</field>
-               <field name="arch" type="xml">
-                   <field name="user_id" position="after">
-                       <field name="categ_id"/>
-                       <field name="stage_id"/>
-                       <field name="delay_close"/>
-                   </field>
-               </field>
-           </record>
-           <record model="ir.ui.view" id="view_crm_fundraising_section_categ_stage_form">
-               <field name="name">CRM Report - Section, Category and Stage(Form)</field>
-               <field name="model">report.crm.fundraising.section.categ.stage</field>
-               <field name="inherit_id" ref="view_crm_case_section_categ_stage_form"/>
-               <field name="type">form</field>
-               <field name="arch" type="xml">
-                   <field name="user_id" position="after">
-                       <field name="categ_id"/>
-                       <field name="stage_id"/>
-                       <field name="delay_close"/>
-                   </field>
-               </field>
-           </record>
-           
-           <record model="ir.ui.view" id="view_crm_fundraising_section_categ_stage_graph">
-               <field name="name">CRM Report - Section, Category and Stage(Select)</field>
-               <field name="model">report.crm.fundraising.section.categ.stage</field>
-               <field name="type">graph</field>
-               <field name="arch" type="xml">
-                   <graph string="Fundraising by Section, Category and Stage" type="bar" orientation="horizontal">
-                       <field name="categ_id"/>
-                       <field name="nbr" operator="+"/>
-                       <field name="section_id" group="True"/>
-                   </graph>
-               </field>
-           </record>
-           <record id="view_crm_fundraising_section_categ_stage_filter" model="ir.ui.view">
-             <field name="name">CRM Report - Section, Category and Stage(Select)</field>
-             <field name="model">report.crm.fundraising.section.categ.stage</field>
-             <field name="inherit_id" ref="view_crm_case_section_categ_filter"/>
-             <field name="type">search</field>
-             <field name="arch" type="xml">
-                 <field name="section_id" position="after">
-                       <field name="categ_id"/>
-                       <field name="stage_id"/>
-                   </field>
-             </field>
+             <field name="view_id" ref="view_crm_fundraising_graph"/>
+             <field name="search_view_id" ref="view_crm_fundraising_filter"/>
          </record>
-       
-           <record model="ir.actions.act_window" id="action_report_crm_fundraising_section_categ_stage_tree">
-               <field name="res_model">report.crm.fundraising.section.categ.stage</field>
-               <field name="name">Fundraising by section, category and stage</field>
-               <field name="view_type">form</field>
-               <field name="view_mode">graph,tree</field>
-               <field name="search_view_id" ref="view_crm_fundraising_section_categ_stage_filter"/>
-           </record>
-           <record model="ir.actions.act_window.view" id="action_crm_fundraising_section_categ_stage_graph">
-               <field name="sequence" eval="1"/>
-               <field name="view_mode">graph</field>
-                       <field name="view_id" ref="view_crm_fundraising_section_categ_stage_graph"/>
-                       <field name="act_window_id" ref="action_report_crm_fundraising_section_categ_stage_tree"/>
-           </record>
-           <record model="ir.actions.act_window.view" id="action_crm_fundraising_section_categ_stage_tree">
-              <field name="sequence" eval="2"/>
-              <field name="view_mode">tree</field>
-              <field name="view_id" ref="view_crm_fundraising_section_categ_stage_tree"/>
-              <field name="act_window_id" ref="action_report_crm_fundraising_section_categ_stage_tree"/>
-           </record>
-         <menuitem action="action_report_crm_fundraising_section_categ_stage_tree" id="menu_crm_fundraising_section_categ_stage_tree" parent="menu_crm_fundraising_tree"/>
          
-         #
-           # Fundraising by section, category and type
-           #
+                       
 -              <record model="ir.actions.act_window.view" id="action_report_crm_phonecall_tree">
++              <record model="ir.actions.act_window.view" id="action_report_crm_fundrising_tree">
+               <field name="sequence" eval="2"/>
+               <field name="view_mode">tree</field>
+               <field name="view_id" ref="view_crm_fundraising_tree"/>
+               <field name="act_window_id" ref="action_report_crm_fundraising"/>
 -          </record>             
 -        <menuitem name="Fundraising" id="menu_crm_fundraising_tree" parent="crm.next_id_52"/>
 -        <menuitem action="action_report_crm_fundraising" id="menu_crm_fundraising_user_tree" parent="menu_crm_fundraising_tree"/>
 -        
++          </record> 
 +
-           <record model="ir.ui.view" id="view_crm_fundraising_section_categ_type_tree">
-               <field name="name">CRM Report - Section, Category and Type(Tree)</field>
-               <field name="model">report.crm.fundraising.section.categ.type</field>
-               <field name="inherit_id" ref="view_crm_case_section_categ_type_tree"/>
-               <field name="type">tree</field>
-               <field name="arch" type="xml">
-                   <field name="user_id" position="after">
-                       <field name="categ_id"/>
-                       <field name="type_id"/>
-                       <field name="stage_id"/>
-                       <field name="delay_close"/>
-                   </field>
-               </field>
-           </record>
-           <record model="ir.ui.view" id="view_crm_fundraising_section_categ_type_form">
-               <field name="name">CRM Report - Section, Category and Type(Form)</field>
-               <field name="model">report.crm.fundraising.section.categ.type</field>
-               <field name="inherit_id" ref="view_crm_case_section_categ_type_form"/>
-               <field name="type">form</field>
-               <field name="arch" type="xml">
-                   <field name="user_id" position="after">
-                       <field name="categ_id"/>
-                       <field name="type_id"/>
-                       <field name="stage_id"/>
-                       <field name="delay_close"/>
-                   </field>
-               </field>
-           </record>
-           
-           <record model="ir.ui.view" id="view_crm_fundraising_section_categ_type_graph">
-               <field name="name">CRM Report - Section, Category and Type(Select)</field>
-               <field name="model">report.crm.fundraising.section.categ.type</field>
-               <field name="type">graph</field>
-               <field name="arch" type="xml">
-                   <graph string="Fundraising by Section, Category and Type" type="bar" orientation="horizontal">
-                       <field name="type_id"/>
-                       <field name="nbr" operator="+"/>
-                       <field name="section_id" group="True"/>
-                   </graph>
-               </field>
-           </record>
-           <record id="view_crm_fundraising_section_categ_type_filter" model="ir.ui.view">
-                   <field name="name">CRM Report - Section, Category and Type(Select)</field>
-                   <field name="model">report.crm.fundraising.section.categ.type</field>
-                   <field name="inherit_id" ref="view_crm_case_section_categ_type_filter"/>
-                   <field name="type">search</field>
-                   <field name="arch" type="xml">
-                       <field name="section_id" position="after">
-                               <field name="categ_id" select="1"/>
-                               <field name="type_id" select="1"/>
-                               <field name="stage_id" select="1"/>
-                           </field>
-                   </field>
-               </record>
-       
-           <record model="ir.actions.act_window" id="action_report_crm_fundraising_section_categ_type_tree">
-               <field name="res_model">report.crm.fundraising.section.categ.type</field>
-               <field name="name">Fundraising by section, category and type</field>
-               <field name="view_type">form</field>
-               <field name="view_mode">graph,tree</field>
-               <field name="search_view_id" ref="view_crm_fundraising_section_categ_type_filter"/>
-           </record>
-           <record model="ir.actions.act_window.view" id="action_crm_fundraising_section_categ_type_graph">
-               <field name="sequence" eval="1"/>
-               <field name="view_mode">graph</field>
-                       <field name="view_id" ref="view_crm_fundraising_section_categ_type_graph"/>
-                       <field name="act_window_id" ref="action_report_crm_fundraising_section_categ_type_tree"/>
-           </record>
-           <record model="ir.actions.act_window.view" id="action_crm_fundraising_section_categ_type_tree">
-              <field name="sequence" eval="2"/>
-              <field name="view_mode">tree</field>
-              <field name="view_id" ref="view_crm_fundraising_section_categ_type_tree"/>
-              <field name="act_window_id" ref="action_report_crm_fundraising_section_categ_type_tree"/>
-           </record>
-         <menuitem action="action_report_crm_fundraising_section_categ_type_tree" id="menu_crm_fundraising_section_categ_type_tree" parent="menu_crm_fundraising_tree"/>
-       </data>
++        <record model="ir.actions.act_window.view" id="action_report_crm_fundrising_graph">
++              <field name="sequence" eval="1"/>
++              <field name="view_mode">graph</field>
++              <field name="view_id" ref="view_crm_fundraising_graph"/>
++              <field name="act_window_id" ref="action_report_crm_fundraising"/>
++          </record>            
++        <menuitem name="Fundraising" action="action_report_crm_fundraising" id="menu_crm_fundraising_tree" parent="crm.next_id_52"/>
++                
+       </data>
  </openerp>
@@@ -21,11 -22,71 +22,15 @@@ class report_crm_lead(osv.osv)
                      c.user_id,
                      c.stage_id,
                      c.section_id,
+                     c.categ_id,
                      count(*) as nbr,
++                    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.state, c.user_id,c.section_id,c.stage_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,categ_id
              )""")
  report_crm_lead()
 -
 -#
 -#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()
 -#
 -
 -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:=======
  # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@@ -58,7 -62,7 +62,7 @@@
          </record>
                
    
--        <record id="action_report_crm_lead_tree" model="ir.actions.act_window">
++        <record id="action_report_crm_lead" model="ir.actions.act_window">
              <field name="name">Leads</field>
              <field name="res_model">report.crm.lead</field>
              <field name="view_type">form</field>
                <field name="sequence" eval="2"/>
                <field name="view_mode">tree</field>
                <field name="view_id" ref="view_crm_lead_tree"/>
-               <field name="act_window_id" ref="action_report_crm_lead_tree"/>
+               <field name="act_window_id" ref="action_report_crm_lead"/>
            </record>        
-       
-             
-         <menuitem name="Leads" id="menu_crm_leads_tree" parent="crm.next_id_52" action="action_report_crm_lead_tree"/>       
+                       
+               <record model="ir.actions.act_window.view" id="action_report_crm_lead_graph">
 -              <field name="sequence" eval="2"/>
++              <field name="sequence" eval="1"/>
+               <field name="view_mode">graph</field>
+               <field name="view_id" ref="view_crm_lead_graph"/>
+               <field name="act_window_id" ref="action_report_crm_lead"/>
+           </record>        
 -
 -            
 -   
 -        
 -       <!--   Leads by Section  
 -
 -        <record id="view_report_crm_lead_section_tree" model="ir.ui.view">
 -            <field name="name">report.crm.lead.section.tree</field>
 -            <field name="model">report.crm.lead.section</field>
 -            <field name="inherit_id" ref="view_report_crm_case_section_tree"/>
 -            <field name="type">tree</field>
 -            <field name="arch" type="xml">
 -                <field name="nbr_cases" position="after">
 -                      <field name="avg_answers"/>
 -                      <field name="perc_done" select="2"/>
 -                    <field name="perc_cancel" select="2"/>
 -                    <field name="delay_close"/>
 -                </field>
 -            </field>
 -        </record>
 -
 -        <record id="view_report_crm_lead_section_graph" model="ir.ui.view">
 -            <field name="name">report.crm.lead.section.graph</field>
 -            <field name="model">report.crm.lead.section</field>
 -            <field name="type">graph</field>
 -            <field name="arch" type="xml">
 -                <graph orientation="horizontal" string="Leads by Section" type="bar">
 -                    <field name="name"/>
 -                    <field name="nbr_cases" operator="+"/>
 -                </graph>
 -            </field>
 -        </record>
 -
 -              <record id="view_report_crm_lead_section_filter" model="ir.ui.view">
 -            <field name="name">report.crm.lead.section.select</field>
 -            <field name="model">report.crm.lead.section</field>
 -            <field name="inherit_id" ref="view_report_crm_case_section_filter"/>
 -            <field name="type">search</field>
 -            <field name="arch" type="xml">
 -                <field name="nbr_cases" position="before">
 -                </field>
 -            </field>
 -        </record>
 -
 -        <record id="action_report_crm_lead_section_tree" model="ir.actions.act_window">
 -            <field name="name">Leads by Section</field>
 -            <field name="res_model">report.crm.lead.section</field>
 -            <field name="view_type">form</field>
 -            <field name="view_mode">graph,tree</field>
 -            <field name="view_id" ref="view_report_crm_lead_section_graph"/>
 -            <field name="search_view_id" ref="view_report_crm_lead_section_filter"/>
 -        </record>
 -        <menuitem action="action_report_crm_lead_section_tree" id="menu_crm_lead_section_tree" parent="menu_crm_leads_tree"/>
 -      -->
 -     
+         <menuitem name="Leads" id="menu_crm_leads_tree" parent="crm.next_id_52" action="action_report_crm_lead"/>       
    </data>
  </openerp>
@@@ -4,14 -4,14 +4,15 @@@ import tool
  class report_crm_opportunity(osv.osv):
      _name = "report.crm.opportunity"    
      _auto = False
-     _inherit = "report.crm.case.user"
 -    _inherit = "report.crm.case"
++    _inherit = "report.crm.case"    
++    
      _columns = {
          'probability': fields.float('Avg. Probability', readonly=True),
          'amount_revenue': fields.float('Est.Revenue', readonly=True),        
          'amount_revenue_prob': fields.float('Est. Rev*Prob.', readonly=True),
          'delay_close': fields.char('Delay to close', size=20, readonly=True),
          'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]"),
--        'stage_id':fields.many2one('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]", readonly=True),
++        'stage_id':fields.many2one('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]", readonly=True),        
      }
      def init(self, cr):
          tools.drop_view_if_exists(cr, 'report_crm_opportunity')
@@@ -27,6 -27,6 +28,9 @@@
                      c.categ_id,
                      c.stage_id,
                      count(*) as nbr,
++                    0 as avg_answers,
++                    0.0 as perc_done,
++                    0.0 as perc_cancel,
                      sum(planned_revenue) as amount_revenue,                    
                      sum(planned_revenue*probability)::decimal(16,2) as amount_revenue_prob,
                      avg(probability)::decimal(16,2) as probability,
@@@ -65,7 -65,7 +65,7 @@@
              </field>
          </record>
          
--        <record id="action_report_crm_opportunity_tree" model="ir.actions.act_window">
++        <record id="action_report_crm_opportunity" model="ir.actions.act_window">
              <field name="name">Opportunity</field>
              <field name="res_model">report.crm.opportunity</field>
              <field name="view_type">form</field>
                <field name="sequence" eval="2"/>
                <field name="view_mode">tree</field>
                <field name="view_id" ref="view_crm_opportunity_tree"/>
-               <field name="act_window_id" ref="action_report_crm_opportunity_tree"/>
-           </record>                
-         <menuitem name="Opportinities" action="action_report_crm_opportunity_tree" id="menu_crm_opportunity_tree" parent="crm.next_id_52"/>        
+               <field name="act_window_id" ref="action_report_crm_opportunity"/>
 -          </record>                
 -
 -        
 -<!--       Opportunity by Section  
 -
 -        <record id="view_report_crm_opportunity_section_tree" model="ir.ui.view">
 -            <field name="name">report.crm.opportunity.section.tree</field>
 -            <field name="model">report.crm.opportunity.section</field>
 -            <field name="inherit_id" ref="view_report_crm_case_section_tree"/>
 -            <field name="type">tree</field>
 -            <field name="arch" type="xml">
 -                <field name="nbr_cases" position="after">
 -                      <field name="avg_answers"/>
 -                      <field name="perc_done" select="2"/>
 -                    <field name="perc_cancel" select="2"/>
 -                    <field name="delay_close"/>
 -                </field>
 -            </field>
 -        </record>
 -
 -        <record id="view_report_crm_opportunity_section_graph" model="ir.ui.view">
 -            <field name="name">report.crm.opportunity.section.graph</field>
 -            <field name="model">report.crm.opportunity.section</field>
 -            <field name="type">graph</field>
 -            <field name="arch" type="xml">
 -                <graph orientation="horizontal" string="Opportunity by Section" type="bar">
 -                    <field name="name"/>
 -                    <field name="nbr_cases" operator="+"/>
 -                </graph>
 -            </field>
 -        </record>
 -
 -              <record id="view_report_crm_opportunity_section_filter" model="ir.ui.view">
 -            <field name="name">report.crm.opportunity.section.select</field>
 -            <field name="model">report.crm.opportunity.section</field>
 -            <field name="inherit_id" ref="view_report_crm_case_section_filter"/>
 -            <field name="type">search</field>
 -            <field name="arch" type="xml">
 -                <field name="nbr_cases" position="before">
 -                </field>
 -            </field>
 -        </record>
 -
 -        <record id="action_report_crm_opportunity_section_tree" model="ir.actions.act_window">
 -            <field name="name">Opportunity by Section</field>
 -            <field name="res_model">report.crm.opportunity.section</field>
 -            <field name="view_type">form</field>
 -            <field name="view_mode">graph,tree</field>
 -            <field name="view_id" ref="view_report_crm_opportunity_section_graph"/>
 -            <field name="search_view_id" ref="view_report_crm_opportunity_section_filter"/>
 -        </record>
 -        <menuitem action="action_report_crm_opportunity_section_tree" id="menu_crm_opportunity_section_tree" parent="menu_crm_opportunity_tree"/>
 -        -->
 -        <menuitem name="Opportinities" action="action_report_crm_opportunity_tree" id="menu_crm_opportunity_tree" parent="crm.next_id_52"/>        
++          </record> 
++        <record model="ir.actions.act_window.view" id="action_report_crm_opportunity_graph">
++              <field name="sequence" eval="1"/>
++              <field name="view_mode">graph</field>
++              <field name="view_id" ref="view_crm_opportunity_graph"/>
++              <field name="act_window_id" ref="action_report_crm_opportunity"/>
++          </record>  
++        <menuitem name="Opportinities" action="action_report_crm_opportunity" id="menu_crm_opportunity_tree" parent="crm.next_id_52"/>        
        </data>
  </openerp>
@@@ -20,96 -21,69 +21,15 @@@ class report_crm_phonecall(osv.osv)
                      c.state,
                      c.user_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_phonecall 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_phonecall_user()
- class report_crm_phonecall_categ(osv.osv):
-     _name = "report.crm.phonecall.categ"
-     _description = "Phone calls 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.phonecall')]"),        
-         'delay_close': fields.char('Delay Close', size=20, readonly=True),
-     }
-     
-     def init(self, cr):
-         tools.drop_view_if_exists(cr, 'report_crm_phonecall_categ')
-         cr.execute("""
-             create or replace view report_crm_phonecall_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,                                        
-                     to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
-                 from
-                     crm_phonecall 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_phonecall_categ()
- class report_crm_phonecall_section(osv.osv):
-     _name = "report.crm.phonecall.section"
-     _description = "Phone calls 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_phonecall 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_phonecall_section')
-         cr.execute("""
-             create or replace view report_crm_phonecall_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,
 -                    count(*) as nbr,                    
 -                    to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
 -                from
 -                    crm_phonecall c
 -                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
 -            )""")
 -report_crm_phonecall()
 -
 -
 -class report_crm_phonecall_section(osv.osv):
 -    _name = "report.crm.phonecall.section"
 -    _description = "Phone calls 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_phonecall 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_phonecall_section')
 -        cr.execute("""
 -            create or replace view report_crm_phonecall_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,
++                    count(*) as nbr, 
                      0 as avg_answers,
                      0.0 as perc_done,
--                    0.0 as perc_cancel,
++                    0.0 as perc_cancel,                   
                      to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
                  from
                      crm_phonecall c
--                group by to_char(c.create_date, 'YYYY'),to_char(c.create_date, 'MM'),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.categ_id
              )""")
--report_crm_phonecall_section()
--
++report_crm_phonecall()
  # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
              </field>
          </record>
  
-         <record id="view_crm_phonecall_user_filter" model="ir.ui.view">
-             <field name="name">report.crm.phonecall.user.select</field>
-             <field name="model">report.crm.phonecall.user</field>
-             <field name="inherit_id" ref="view_crm_case_user_filter"/>
+         <record id="view_crm_phonecall_filter" model="ir.ui.view">
+             <field name="name">report.crm.phonecall.select</field>
+             <field name="model">report.crm.phonecall</field>
              <field name="type">search</field>
              <field name="arch" type="xml">
-                 <field name="state" position="before">
-                </field>
 -                              <search string="Search Cases by User">
++                              <search string="Search">
+                   <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"/>
+                           <field name="user_id" select="1"/>
+                                               <field name="section_id" select="1"/>
+                           <field name="nbr" select="1"/>
+                           <field name="state" select="1"/>
+                    </group>
+                   <newline/>
+                   <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="Month" icon="terp-sale" domain="[]" context="{'group_by':'month'}"/>
+                       <filter string="Category" icon="terp-sale" domain="[]" context="{'group_by':'categ_id'}"/>
+                    </group>
+                </search>
+             
              </field>
          </record>
          
-         <record id="action_report_crm_phonecall_user_tree" model="ir.actions.act_window">
-             <field name="name">Phone calls by User and Section</field>
-             <field name="res_model">report.crm.phonecall.user</field>
-             <field name="view_type">form</field>
-             <field name="view_mode">graph,tree</field>
-             <field name="view_id" ref="view_crm_phonecall_user_graph"/>
-             <field name="search_view_id" ref="view_crm_phonecall_user_filter"/>
-         </record>
-         <menuitem name="Phone Calls" id="menu_crm_phonecalls_tree" parent="crm.next_id_52"/>
-         <menuitem action="action_report_crm_phonecall_user_tree" id="menu_crm_phonecall_user_tree" parent="menu_crm_phonecalls_tree"/>
-         
-         <!-- # Phonecalls by section and category of case -->
-         <record id="view_crm_phonecall_categ_tree" model="ir.ui.view">
-             <field name="name">report.crm.phonecall.categ.tree</field>
-             <field name="model">report.crm.phonecall.categ</field>
-             <field name="inherit_id" ref="view_crm_case_categ_tree"/>
-             <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_revenue_prob"/>
-                     <field name="probability"/>
-                 </field>
-             </field>
-         </record>
-         <record id="view_crm_phonecall_categ_form" model="ir.ui.view">
-             <field name="name">report.crm.phonecall.categ.form</field>
-             <field name="model">report.crm.phonecall.categ</field>
-             <field name="inherit_id" ref="view_crm_case_categ_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_revenue_prob"/>
-                     <field name="probability"/>
-                 </field>
-             </field>
-         </record>
-               <record id="view_crm_phonecall_categ_graph" model="ir.ui.view">
-             <field name="name">report.crm.phonecall.categ.graph</field>
-             <field name="model">report.crm.phonecall.categ</field>
-             <field name="type">graph</field>
-             <field name="arch" type="xml">
-                 <graph orientation="horizontal" string="Phone calls by Section and Categories" type="bar">
-                     <field name="state"/>
-                     <field name="nbr" operator="+"/>
-                     <field group="True" name="categ_id"/>
-                 </graph>
-             </field>
-         </record>
-               <record id="view_crm_phonecall_categ_filter" model="ir.ui.view">
-             <field name="name">report.crm.phonecall.categ.select</field>
-             <field name="model">report.crm.phonecall.categ</field>
-                       <field name="inherit_id" ref="view_crm_case_categ_filter"/>
-             <field name="type">search</field>
-             <field name="arch" type="xml">
-                 <field name="state" position="before">
-                 </field>
-             </field>
-         </record>
-         <record id="action_report_crm_phonecall_categ_tree" model="ir.actions.act_window">
-             <field name="name">Phone calls by Categories and Section</field>
-             <field name="res_model">report.crm.phonecall.categ</field>
+         <record id="action_report_crm_phonecall" model="ir.actions.act_window">
 -            <field name="name">Phone calls by User and Section</field>
++            <field name="name">Phone calls</field>
+             <field name="res_model">report.crm.phonecall</field>
              <field name="view_type">form</field>
              <field name="view_mode">graph,tree</field>
-             <field name="view_id" ref="view_crm_phonecall_categ_graph"/>
-             <field name="search_view_id" ref="view_crm_phonecall_categ_filter"/>
+             <field name="view_id" ref="view_crm_phonecall_graph"/>
+             <field name="search_view_id" ref="view_crm_phonecall_filter"/>
          </record>
-         <menuitem action="action_report_crm_phonecall_categ_tree" id="menu_crm_phonecall_categ_tree" parent="menu_crm_phonecalls_tree"/>
-         
-         <!-- Phone calls by Section  -->
+                       
+               <record model="ir.actions.act_window.view" id="action_report_crm_phonecall_tree">
+               <field name="sequence" eval="2"/>
+               <field name="view_mode">tree</field>
+               <field name="view_id" ref="view_crm_phonecall_tree"/>
+               <field name="act_window_id" ref="action_report_crm_phonecall"/>
 -          </record>        
 -              
 -        <menuitem name="Phone Calls" id="menu_crm_phonecalls_tree" parent="crm.next_id_52"/>
 -        <menuitem action="action_report_crm_phonecall" id="menu_crm_phonecall_tree" parent="menu_crm_phonecalls_tree"/>
 -        
 -<!--           Phone calls by Section  
 -
 -        <record id="view_report_crm_phonecall_section_tree" model="ir.ui.view">
 -            <field name="name">report.crm.phonecall.section.tree</field>
 -            <field name="model">report.crm.phonecall.section</field>
 -            <field name="inherit_id" ref="view_report_crm_case_section_tree"/>
 -            <field name="type">tree</field>
 -            <field name="arch" type="xml">
 -                <field name="nbr_cases" position="after">
 -                      <field name="avg_answers"/>
 -                      <field name="perc_done" select="2"/>
 -                    <field name="perc_cancel" select="2"/>
 -                    <field name="delay_close"/>
 -                </field>
 -            </field>
 -        </record>
 -
 -        <record id="view_report_crm_phonecall_section_graph" model="ir.ui.view">
 -            <field name="name">report.crm.phonecall.section.graph</field>
 -            <field name="model">report.crm.phonecall.section</field>
 -            <field name="type">graph</field>
 -            <field name="arch" type="xml">
 -                <graph orientation="horizontal" string="Phone calls by Section" type="bar">
 -                    <field name="name"/>
 -                    <field name="nbr_cases" operator="+"/>
 -                </graph>
 -            </field>
 -        </record>
 -
 -              <record id="view_report_crm_phonecall_section_filter" model="ir.ui.view">
 -            <field name="name">report.crm.phonecall.section.select</field>
 -            <field name="model">report.crm.phonecall.section</field>
 -            <field name="inherit_id" ref="view_report_crm_case_section_filter"/>
 -            <field name="type">search</field>
 -            <field name="arch" type="xml">
 -                <field name="nbr_cases" position="before">
 -                </field>
 -            </field>
 -        </record>
++          </record>  
  
-         <record id="view_report_crm_phonecall_section_tree" model="ir.ui.view">
-             <field name="name">report.crm.phonecall.section.tree</field>
-             <field name="model">report.crm.phonecall.section</field>
-             <field name="inherit_id" ref="view_report_crm_case_section_tree"/>
-             <field name="type">tree</field>
-             <field name="arch" type="xml">
-                 <field name="nbr_cases" position="after">
-                       <field name="avg_answers"/>
-                       <field name="perc_done" select="2"/>
-                     <field name="perc_cancel" select="2"/>
-                     <field name="delay_close"/>
-                 </field>
-             </field>
-         </record>
-         <record id="view_report_crm_phonecall_section_graph" model="ir.ui.view">
-             <field name="name">report.crm.phonecall.section.graph</field>
-             <field name="model">report.crm.phonecall.section</field>
-             <field name="type">graph</field>
-             <field name="arch" type="xml">
-                 <graph orientation="horizontal" string="Phone calls by Section" type="bar">
-                     <field name="name"/>
-                     <field name="nbr_cases" operator="+"/>
-                 </graph>
-             </field>
-         </record>
-               <record id="view_report_crm_phonecall_section_filter" model="ir.ui.view">
-             <field name="name">report.crm.phonecall.section.select</field>
-             <field name="model">report.crm.phonecall.section</field>
-             <field name="inherit_id" ref="view_report_crm_case_section_filter"/>
-             <field name="type">search</field>
-             <field name="arch" type="xml">
-                 <field name="nbr_cases" position="before">
-                 </field>
-             </field>
-         </record>
--        <record id="action_report_crm_phonecall_section_tree" model="ir.actions.act_window">
--            <field name="name">Phone calls by Section</field>
--            <field name="res_model">report.crm.phonecall.section</field>
--            <field name="view_type">form</field>
--            <field name="view_mode">graph,tree</field>
--            <field name="view_id" ref="view_report_crm_phonecall_section_graph"/>
--            <field name="search_view_id" ref="view_report_crm_phonecall_section_filter"/>
--        </record>
-         <menuitem action="action_report_crm_phonecall_section_tree" id="menu_crm_phonecall_section_tree" parent="menu_crm_phonecalls_tree"/>
 -        <menuitem action="action_report_crm_phonecall_section_tree" id="menu_crm_phonecall_section_tree" parent="menu_crm_phonecalls_tree"/>-->-->
 -        
++        <record model="ir.actions.act_window.view" id="action_report_crm_phonecall_graph">
++              <field name="sequence" eval="1"/>
++              <field name="view_mode">graph</field>
++              <field name="view_id" ref="view_crm_phonecall_graph"/>
++              <field name="act_window_id" ref="action_report_crm_phonecall"/>
++          </record>         
++              
++        <menuitem name="Phone Calls" action="action_report_crm_phonecall" id="menu_crm_phonecalls_tree" parent="crm.next_id_52"/>
++                
    </data>
  </openerp>
@@@ -1,17 -1,17 +1,13 @@@
  <?xml version="1.0" encoding="utf-8"?>
  <openerp>
--    <data>
 -
 -        <!--
 -              Cases by user and section
 -              -->
++    <data>       
  
-         <!--
-               Cases by user and section
-               -->
-         <record id="view_crm_case_user_tree" model="ir.ui.view">
-             <field name="name">report.crm.case.user.tree</field>
-             <field name="model">report.crm.case.user</field>
+         <record id="view_crm_case_tree" model="ir.ui.view">
+             <field name="name">report.crm.case.tree</field>
+             <field name="model">report.crm.case</field>
              <field name="type">tree</field>
              <field name="arch" type="xml">
-                 <tree string="Cases by User and Section">
 -                <tree string="Cases and Section">
++                <tree string="Cases">
                      <field name="name" />
                      <field name="month"/>
                      <field name="user_id"/>
                  </tree>
              </field>
          </record>
-         <record id="view_crm_case_user_form" model="ir.ui.view">
-             <field name="name">report.crm.case.user.form</field>
-             <field name="model">report.crm.case.user</field>
+         <record id="view_crm_case_form" model="ir.ui.view">
+             <field name="name">report.crm.case.form</field>
+             <field name="model">report.crm.case</field>
              <field name="type">form</field>
              <field name="arch" type="xml">
--                <form string="Cases by User and Section">
++                <form string="Cases">
                      <field name="name" select="1"/>
                      <field name="month" select="1"/>
                      <field name="user_id" select="1"/>
              </field>
          </record>
  
-         <record id="view_crm_case_user_filter" model="ir.ui.view">
-             <field name="name">report.crm.case.user.select</field>
-             <field name="model">report.crm.case.user</field>
+         <record id="view_crm_case_filter" model="ir.ui.view">
+             <field name="name">report.crm.case.select</field>
+             <field name="model">report.crm.case</field>
              <field name="type">search</field>
              <field name="arch" type="xml">
--                <search string="Search Cases by User">
++                <search string="Search">
                    <group col="16" colspan="8">
                                <filter string="My Cases" icon="terp-hr" domain="[('user_id','=',uid)]" help="My cases by section"/>
                                <separator orientation="vertical"/>
          <menuitem id="crm.next_id_52" name="Cases" parent="base.next_id_64" sequence="0"/>
  
  
-         <record id="action_report_crm_case_user_tree" model="ir.actions.act_window">
-             <field name="name">Cases by User and Section</field>
-             <field name="res_model">report.crm.case.user</field>
+         <record id="action_report_crm_case_tree" model="ir.actions.act_window">
 -            <field name="name">Cases by User and Section</field>
++            <field name="name">Cases</field>
+             <field name="res_model">report.crm.case</field>
              <field name="view_type">form</field>
              <field name="view_mode">tree,graph</field>
-             <field name="search_view_id" ref="view_crm_case_user_filter"/>
+             <field name="search_view_id" ref="view_crm_case_filter"/>
          </record>
          <!--<menuitem action="action_report_crm_case_user_tree" id="menu_crm_case_user_tree" parent="crm.next_id_52"/>
  -->
-         <!-- # Cases by section and categoryof case -->
-         <record id="view_crm_case_categ_tree" model="ir.ui.view">
-             <field name="name">report.crm.case.categ.tree</field>
-             <field name="model">report.crm.case.categ</field>
-             <field name="type">tree</field>
-             <field name="arch" type="xml">
-                 <tree string="Cases by User and Section">
-                     <field name="name"/>
-                                       <field name="section_id" select="1"/>
-                     <field name="month"/>
-                     <field name="nbr"/>
-                     <field name="state"/>
-                 </tree>
-             </field>
-         </record>
-         <record id="view_crm_case_categ_form" model="ir.ui.view">
-             <field name="name">report.crm.case.categ.form</field>
-             <field name="model">report.crm.case.categ</field>
-             <field name="type">form</field>
-             <field name="arch" type="xml">
-                 <form string="Cases by User and Section">
-                     <field name="name" select="1"/>
-                                       <field name="section_id" select="1"/>
-                     <field name="month" select="1"/>
-                     <field name="nbr" select="1"/>
-                     <field name="state" select="1"/>
-                 </form>
-             </field>
-         </record>
-               <record id="view_crm_case_categ_filter" model="ir.ui.view">
-             <field name="name">report.crm.case.categ.select</field>
-             <field name="model">report.crm.case.categ</field>
-             <field name="type">search</field>
-             <field name="arch" type="xml">
-                 <search string="Search Cases by categories and Sections">
-                    <group col="12" colspan="4">
-                               <filter string="This Year" icon="terp-hr" domain="[('name','=',time.localtime()[0])]"/>
-                                               <filter string="This Month" icon="terp-hr" domain="[('month','=',time.strftime('%%m'))]"/>
-                                               <separator orientation="vertical"/>
-                                               <field name="name" select="1"/>
-                                               <field name="section_id" select="1"/>
-                           <field name="nbr" select="1"/>
-                           <field name="state" select="1"/>
-                    </group>
-                </search>
-             </field>
-         </record>
-         <record id="action_report_crm_case_categ_tree" model="ir.actions.act_window">
-             <field name="name">Cases by Categories and Section</field>
-             <field name="res_model">report.crm.case.categ</field>
-             <field name="view_type">form</field>
-             <field name="view_mode">tree,graph</field>
-             <field name="search_view_id" ref="view_crm_case_categ_filter"/>
-         </record>
         <!-- <menuitem action="action_report_crm_case_categ_tree" id="menu_crm_case_categ_tree" parent="crm.next_id_52"/>-->
  
-         <act_window domain="[('user_id', '=', active_id)]" id="act_res_users_2_report_crm_case_user" name="Monthly cases" res_model="report.crm.case.user" src_model="res.users"/>
-         <act_window domain="[('section_id', '=', active_id)]" id="act_crm_case_section_2_report_crm_case_user" name="Monthly cases by user" res_model="report.crm.case.user" src_model="crm.case.section"/>
-         <act_window domain="[('section_id', '=', active_id)]" id="act_crm_case_section_2_report_crm_case_categ" name="Monthly cases by section" res_model="report.crm.case.categ" src_model="crm.case.section"/>
+         <act_window domain="[('user_id', '=', active_id)]" id="act_res_users_2_report_crm_case_user" name="Monthly cases" res_model="report.crm.case" src_model="res.users"/>
  
-         <!-- Cases by Section  -->
+         <act_window domain="[('section_id', '=', active_id)]" id="act_crm_case_section_2_report_crm_case_user" name="Monthly cases by user" res_model="report.crm.case" src_model="crm.case.section"/>
  
-         <record id="view_report_crm_case_section_tree" model="ir.ui.view">
-             <field name="name">report.crm.case.section.tree</field>
-             <field name="model">report.crm.case.section</field>
-             <field name="type">tree</field>
-             <field name="arch" type="xml">
-                 <tree string="Cases by Section">
-                     <field name="name" select="1"/>
-                                       <field name="section_id" select="1"/>
-                     <field name="month" select="1"/>
-                     <field name="nbr_cases" select="1"/>
-                     <field name="avg_answers"/>
-                 </tree>
-             </field>
-         </record>
-         <record id="view_report_crm_case_section_graph" model="ir.ui.view">
-             <field name="name">report.crm.case.section.graph</field>
-             <field name="model">report.crm.case.section</field>
-             <field name="type">graph</field>
-             <field name="arch" type="xml">
-                 <graph orientation="horizontal" string="Cases by Section" type="bar">
-                     <field name="name"/>
-                     <field name="nbr_cases" operator="+"/>
-                 </graph>
-             </field>
-         </record>
+         <act_window domain="[('section_id', '=', active_id)]" id="act_crm_case_section_2_report_crm_case_categ" name="Monthly cases by section" res_model="report.crm.case" src_model="crm.case.section"/>
  
-               <record id="view_report_crm_case_section_filter" model="ir.ui.view">
-             <field name="name">report.crm.case.section.select</field>
-             <field name="model">report.crm.case.section</field>
-             <field name="type">search</field>
-             <field name="arch" type="xml">
-                 <search string="Search Cases by Section">
-                    <group col="8" colspan="4">
-                               <filter string="This Year" icon="terp-hr" domain="[('name','=',time.localtime()[0])]"/>
-                                               <filter string="This Month" icon="terp-hr" domain="[('month','=',time.strftime('%%m'))]"/>
-                                               <separator orientation="vertical"/>
-                                               <field name="name" select="1"/>
-                                               <field name="section_id" select="1"/>
-                           <field name="month" select="1"/>
-                           <field name="nbr_cases" select="1"/>
-                    </group>
-                </search>
-             </field>
-         </record>
-         <record id="action_report_crm_case_section_tree" model="ir.actions.act_window">
-             <field name="name">Cases by Section</field>
-             <field name="res_model">report.crm.case.section</field>
-             <field name="view_type">form</field>
-             <field name="view_mode">graph,tree</field>
-             <field name="search_view_id" ref="view_report_crm_case_section_filter"/>
-         </record>
-               #
-           # Cases by section and stage
-           #
-               <record model="ir.ui.view" id="view_crm_case_section_stage_tree">
-         <field name="name">CRM Report - Sections and Stage(Tree)</field>
-         <field name="model">report.crm.case.section.stage</field>
-         <field name="type">tree</field>
-         <field name="arch" type="xml">
-             <tree string="Cases by Section and Stage">
-                 <field name="name"/>
-                 <field name="month"/>
-                 <field name="user_id"/>
-                 <field name="section_id"/>
-                 <field name="nbr"/>
-                 <field name="state"/>
-             </tree>
-         </field>
-     </record>
-     <record model="ir.ui.view" id="view_crm_case_section_stage_form">
-         <field name="name">CRM Report - Sections and Stage(Form)</field>
-         <field name="model">report.crm.case.section.stage</field>
-         <field name="type">form</field>
-         <field name="arch" type="xml">
-             <form string="Cases by Section and Stage">
-                 <field name="name"/>
-                 <field name="month"/>
-                 <field name="user_id"/>
-                 <field name="section_id" select="1" widget="selection"/>
-                 <field name="nbr" select="1"/>
-                 <field name="state" select="1"/>
-             </form>
-         </field>
-     </record>
-       <record id="view_crm_case_section_stage_filter" model="ir.ui.view">
-             <field name="name">CRM Report - Sections and Stage(Select)</field>
-             <field name="model">report.crm.case.section.stage</field>
-             <field name="type">search</field>
-             <field name="arch" type="xml">
-                 <search string="Cases by Section and Stage">
-                    <group col="8" colspan="4">
-                               <filter string="This Year" icon="terp-hr" domain="[('name','=',time.localtime()[0])]" help="Cases by Section and Stage for this year"/>
-                                               <filter string="This Month" icon="terp-hr" domain="[('month','=',time.strftime('%%m'))]" help="Cases by Section and Stage for this month"/>
-                                               <separator orientation="vertical"/>
-                                               <field name="section_id" select="1" widget="selection"/>
-                               <field name="nbr" select="1"/>
-                               <field name="state" select="1"/>
-                    </group>
-                </search>
-             </field>
-         </record>
-     <record model="ir.actions.act_window" id="action_report_crm_case_section_stage_tree">
-         <field name="res_model">report.crm.case.section.stage</field>
-         <field name="view_type">form</field>
-         <field name="view_mode">tree</field>
-         <field name="search_view_id" ref="view_crm_case_section_stage_filter"/>
-     </record>
-     
-     #
-     # Cases by section and type of case
-     #
-     <record model="ir.ui.view" id="view_crm_case_section_categ_tree">
-         <field name="name">CRM Report - Sections and Type(Tree)</field>
-         <field name="model">report.crm.case.section.type</field>
-         <field name="type">tree</field>
-         <field name="arch" type="xml">
-             <tree string="Cases by Section and Type">
-                 <field name="name"/>
-                 <field name="month"/>
-                 <field name="user_id"/>
-                 <field name="section_id"/>
-                 <field name="nbr"/>
-                 <field name="state"/>
-             </tree>
-         </field>
-     </record>
-     <record model="ir.ui.view" id="view_crm_case_section_categ_form">
-         <field name="name">CRM Report - Sections and Type(Form)</field>
-         <field name="model">report.crm.case.section.type</field>
-         <field name="type">form</field>
-         <field name="arch" type="xml">
-             <form string="Cases by Section and Type">
-                 <field name="name"/>
-                 <field name="month"/>
-                 <field name="user_id"/>
-                 <field name="section_id" select="1" widget="selection"/>
-                 <field name="nbr" select="1"/>
-                 <field name="state" select="1"/>
-             </form>
-         </field>
-     </record>
-     <record id="view_crm_case_section_categ_filter" model="ir.ui.view">
-             <field name="name">CRM Report - Sections and Type(Select)</field>
-             <field name="model">report.crm.case.section.type</field>
-             <field name="type">search</field>
-             <field name="arch" type="xml">
-                 <search string="Cases by Section and Type">
-                    <group col="10" colspan="4">
-                               <filter string="This Year" icon="terp-hr" domain="[('name','=',time.localtime()[0])]" help="Cases by Section and Type for this year"/>
-                                               <filter string="This Month" icon="terp-hr" domain="[('month','=',time.strftime('%%m'))]" help="Cases by Section and Type for this month"/>
-                                               <separator orientation="vertical"/>
-                                               <field name="section_id" select="1" widget="selection"/>
-                               <field name="nbr" select="1"/>
-                               <field name="state" select="1"/>
-                    </group>
-                </search>
-             </field>
-         </record>
-     <record model="ir.actions.act_window" id="action_report_crm_case_section_categ_tree">
-         <field name="res_model">report.crm.case.section.type</field>
-         <field name="view_type">form</field>
-         <field name="view_mode">tree</field>
-         <field name="search_view_id" ref="view_crm_case_section_categ_filter"/>
-     </record>
-     
-     #
-     # Cases by section, category and stage
-     #
-     <record model="ir.ui.view" id="view_crm_case_section_categ_stage_tree">
-         <field name="name">CRM Report - Section, Category and Stage(Tree)</field>
-         <field name="model">report.crm.case.section.categ.stage</field>
-         <field name="type">tree</field>
-         <field name="arch" type="xml">
-             <tree string="Cases by Section, Category and Stage">
-                 <field name="name"/>
-                 <field name="month"/>
-                 <field name="user_id"/>
-                 <field name="section_id"/>
-                 <field name="nbr"/>
-                 <field name="state"/>
-             </tree>
-         </field>
-     </record>
-     <record model="ir.ui.view" id="view_crm_case_section_categ_stage_form">
-         <field name="name">CRM Report - Section, Category and Stage(Form)</field>
-         <field name="model">report.crm.case.section.categ.stage</field>
-         <field name="type">form</field>
-         <field name="arch" type="xml">
-             <form string="Cases by Section, Category and Stage">
-                 <field name="name"/>
-                 <field name="month"/>
-                 <field name="user_id"/>
-                 <field name="section_id" select="1" widget="selection"/>
-                 <field name="nbr" select="1"/>
-                 <field name="state" select="1"/>
-             </form>
-         </field>
-     </record>
-     <record id="view_crm_case_section_categ_stage_filter" model="ir.ui.view">
-             <field name="name">CRM Report - Section, Category and Stage(Select)</field>
-             <field name="model">report.crm.case.section.categ.stage</field>
-             <field name="type">search</field>
-             <field name="arch" type="xml">
-                 <search string="Cases by Section, Category and Stage">
-                    <group col='8' colspan='4'>
-                               <filter string="This Year" icon="terp-hr" domain="[('name','=',time.localtime()[0])]" help="Cases by Section, Category and Stage for this year"/>
-                                               <filter string="This Month" icon="terp-hr" domain="[('month','=',time.strftime('%%m'))]" help="Cases by Section, Category and Stage for this month"/>
-                                               <separator orientation="vertical"/>
-                                               <field name="section_id" select="1" widget="selection"/>
-                                               <field name="nbr" select="1"/>
-                               <field name="state" select="1"/>
-                    </group>
-                </search>
-             </field>
-         </record>
-       
-     <record model="ir.actions.act_window" id="action_report_crm_case_section_categ_stage_tree">
-         <field name="res_model">report.crm.case.section.categ.stage</field>
-         <field name="view_type">form</field>
-         <field name="view_mode">tree</field>
-         <field name="search_view_id" ref="view_crm_case_section_categ_stage_filter"/>
-     </record>
-     #
-     # Cases by section, category and type
-     #
-     <record model="ir.ui.view" id="view_crm_case_section_categ_type_tree">
-         <field name="name">CRM Report - Section, Category and Type(Tree)</field>
-         <field name="model">report.crm.case.section.categ.type</field>
-         <field name="type">tree</field>
-         <field name="arch" type="xml">
-             <tree string="Cases by Section, Category and Type">
-                 <field name="name"/>
-                 <field name="month"/>
-                 <field name="user_id"/>
-                 <field name="section_id"/>
-                 <field name="nbr"/>
-                 <field name="state"/>
-             </tree>
-         </field>
-     </record>
-     <record model="ir.ui.view" id="view_crm_case_section_categ_type_form">
-         <field name="name">CRM Report - Section, Category and Type(Form)</field>
-         <field name="model">report.crm.case.section.categ.type</field>
-         <field name="type">form</field>
-         <field name="arch" type="xml">
-             <form string="Cases by Section, Category and Type">
-                 <field name="name"/>
-                 <field name="month"/>
-                 <field name="user_id"/>
-                 <field name="section_id" select="1" widget="selection"/>
-                 <field name="nbr" select="1"/>
-                 <field name="state" select="1"/>
-             </form>
-         </field>
-     </record>
-       <record id="view_crm_case_section_categ_type_filter" model="ir.ui.view">
-             <field name="name">CRM Report - Section, Category and Type(Select)</field>
-             <field name="model">report.crm.case.section.categ.type</field>
-             <field name="type">search</field>
-             <field name="arch" type="xml">
-                 <search string="Search Cases by User">
-                    <group col='12' colspan='4'>
-                               <filter string="This Year" icon="terp-hr" domain="[('name','=',time.localtime()[0])]" help="Cases by User for this year"/>
-                                               <filter string="This Month" icon="terp-hr" domain="[('month','=',time.strftime('%%m'))]" help="Cases by User for this month"/>
-                                               <separator orientation="vertical"/>
-                                               <field name="section_id" select="1" widget="selection"/>
-                                               <field name="nbr" select="1"/>
-                               <field name="state" select="1"/>
-                    </group>
-                </search>
-             </field>
-     </record>
 -        <!-- Cases by Section  -->
 -
 -        <record id="view_report_crm_case_section_tree" model="ir.ui.view">
 -            <field name="name">report.crm.case.section.tree</field>
 -            <field name="model">report.crm.case.section</field>
 -            <field name="type">tree</field>
 -            <field name="arch" type="xml">
 -                <tree string="Cases by Section">
 -                    <field name="name" select="1"/>
 -                                      <field name="section_id" select="1"/>
 -                    <field name="month" select="1"/>
 -                    <field name="nbr_cases" select="1"/>
 -                    <field name="avg_answers"/>
 -                </tree>
 -            </field>
 -        </record>
 -
 -        <record id="view_report_crm_case_section_graph" model="ir.ui.view">
 -            <field name="name">report.crm.case.section.graph</field>
 -            <field name="model">report.crm.case.section</field>
 -            <field name="type">graph</field>
 -            <field name="arch" type="xml">
 -                <graph orientation="horizontal" string="Cases by Section" type="bar">
 -                    <field name="name"/>
 -                    <field name="nbr_cases" operator="+"/>
 -                </graph>
 -            </field>
 -        </record>
 -
 -              <record id="view_report_crm_case_section_filter" model="ir.ui.view">
 -            <field name="name">report.crm.case.section.select</field>
 -            <field name="model">report.crm.case.section</field>
 -            <field name="type">search</field>
 -            <field name="arch" type="xml">
 -                <search string="Search Cases by Section">
 -                   <group col="8" colspan="4">
 -                              <filter string="This Year" icon="terp-hr" domain="[('name','=',time.localtime()[0])]"/>
 -                                              <filter string="This Month" icon="terp-hr" domain="[('month','=',time.strftime('%%m'))]"/>
 -                                              <separator orientation="vertical"/>
 -                                              <field name="name" select="1"/>
 -                                              <field name="section_id" select="1"/>
 -                          <field name="month" select="1"/>
 -                          <field name="nbr_cases" select="1"/>
 -                   </group>
 -               </search>
 -            </field>
 -        </record>
 -
 -
 -        <record id="action_report_crm_case_section_tree" model="ir.actions.act_window">
 -            <field name="name">Cases by Section</field>
 -            <field name="res_model">report.crm.case.section</field>
 -            <field name="view_type">form</field>
 -            <field name="view_mode">graph,tree</field>
 -            <field name="search_view_id" ref="view_report_crm_case_section_filter"/>
 -        </record>
++        
  
-     <record model="ir.actions.act_window" id="action_report_crm_case_section_categ_type_tree">
-         <field name="res_model">report.crm.case.section.categ.type</field>
-         <field name="view_type">form</field>
-         <field name="view_mode">tree</field>
-         <field name="search_view_id" ref="view_crm_case_section_categ_type_filter"/>
-     </record>
  
          <!-- Closed & Open CRM Case view for Random Activities dashboard  -->