import crm_fundraising
import crm_helpdesk
-import crm_report
-#import report
+
- #import report
++import report
import wizard
'category': 'Generic Modules/CRM & SRM',
'description': """The generic Open ERP Customer Relationship Management
system enables a group of people to intelligently and efficiently manage
--leads, opportunities, tasks, issues, requests, bugs, campaign, claims, etc.
++leads, opportunities, claims, meeting, phonecall etc.
It manages key tasks such as communication, identification, prioritization,
assignment, resolution and notification.
'crm_claims_view.xml',
'crm_claims_menu.xml',
--# 'crm_report_view.xml',
'crm_helpdesk_view.xml',
'crm_helpdesk_menu.xml',
-- #'crm_report.xml',
++
'security/crm_security.xml',
'security/ir.model.access.csv',
- 'process/crm_configuration_process.xml'
- 'crm_report/crm_report_view.xml',
- 'crm_report/crm_report_claim_view.xml',
- 'crm_report/crm_report_lead_view.xml',
- 'crm_report/crm_report_fundraising_view.xml',
- 'crm_report/crm_report_opportunity_view.xml' ,
- 'crm_report/crm_report_phonecall_view.xml',
++ 'report/crm_report_view.xml',
++ 'report/crm_report_claim_view.xml',
++ 'report/crm_report_lead_view.xml',
++ 'report/crm_report_fundraising_view.xml',
++ 'report/crm_report_opportunity_view.xml' ,
++ 'report/crm_report_phonecall_view.xml',
+
+ 'process/crm_configuration_process.xml',
+
],
'demo_xml': [
'crm_demo.xml',
#
##############################################################################
--import report_businessopp
++#import report_businessopp
import crm_report
++import crm_report_claim
++import crm_report_lead
++import crm_report_phonecall
++import crm_report_fundraising
++import crm_report_opportunity
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
##############################################################################
from osv import fields,osv
--
--import tools.sql
++import tools
AVAILABLE_STATES = [
('draft','Draft'),
('pending','Pending')
]
--class report_crm_case_section_categ2(osv.osv):
-- _name = "report.crm.case.section.categ2"
-- _description = "Cases by section and category2"
++class report_crm_case(osv.osv):
++ _name = "report.crm.case"
++ _description = "Cases and section"
_auto = False
-- _columns = {
-- 'name': fields.char('Year',size=64,required=False, 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),
-- 'user_id':fields.many2one('res.users', 'User', readonly=True),
-- 'section_id':fields.many2one('crm.case.section', 'Section', readonly=True),
-- 'category2_id':fields.many2one('crm.case.category2', 'Type', readonly=True),
-- 'stage_id':fields.many2one('crm.case.stage', 'Stage', readonly=True),
-- 'amount_revenue': fields.float('Est.Revenue', readonly=True),
-- 'nbr': fields.integer('# of Cases', readonly=True),
-- 'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True),
-- 'delay_close': fields.char('Delay Close', size=20, readonly=True),
-- }
-- _order = 'category2_id, section_id'
-- def init(self, cr):
-- tools.sql.drop_view_if_exists(cr, "report_crm_case_section_categ2")
-- cr.execute("""
-- create view report_crm_case_section_categ2 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.category2_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_case c
-- where c.category2_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.category2_id, c.section_id)""")
--
--report_crm_case_section_categ2()
++ 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) ) * 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
++ res[case.id] = avg_ans
++
++ return res
--class report_crm_case_section_stage(osv.osv):
-- _name = "report.crm.case.section.stage"
-- _description = "Cases by section and stage"
-- _auto = False
_columns = {
'name': fields.char('Year',size=64,required=False, 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),
'user_id':fields.many2one('res.users', 'User', readonly=True),
-- 'section_id':fields.many2one('crm.case.section', 'Section', readonly=True),
-- 'categ_id':fields.many2one('crm.case.categ', 'Category', readonly=True),
-- 'stage_id':fields.many2one('crm.case.stage', 'Stage', readonly=True),
-- 'amount_revenue': fields.float('Est.Revenue', readonly=True),
++ 'section_id':fields.many2one('crm.case.section', 'Section', readonly=True),
'nbr': fields.integer('# of Cases', readonly=True),
'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True),
-- 'delay_close': fields.char('Delay Close', size=20, readonly=True),
-- }
-- _order = 'stage_id, section_id'
--
-- def init(self, cr):
-- tools.sql.drop_view_if_exists(cr, "report_crm_case_section_stage")
-- cr.execute("""
-- create view report_crm_case_section_stage as (
-- select
-- min(c.id) as id,
-- to_char(c.create_date,'YYYY') as name,
-- to_char(c.create_date, 'MM') as month,
-- c.user_id,
-- c.state,
-- c.stage_id,
-- c.section_id,
-- c.categ_id,
-- count(*) as nbr,
-- sum(planned_revenue) as amount_revenue,
-- to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
-- from
-- crm_case c
-- where c.stage_id is not null
-- group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.user_id, c.state, c.stage_id, c.categ_id, c.section_id)""")
--
--report_crm_case_section_stage()
--
--class report_crm_case_section_categ_stage(osv.osv):
-- _name = "report.crm.case.section.categ.stage"
-- _description = "Cases by section, Category and stage"
-- _auto = False
-- _columns = {
-- 'name': fields.char('Year',size=64,required=False, 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),
-- 'user_id':fields.many2one('res.users', 'User', readonly=True),
-- 'categ_id':fields.many2one('crm.case.categ', 'Category', readonly=True),
-- 'section_id':fields.many2one('crm.case.section', 'Section', readonly=True),
-- 'stage_id':fields.many2one('crm.case.stage', 'Stage', readonly=True),
-- 'nbr': fields.integer('# of Cases', readonly=True),
-- 'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True),
-- 'delay_close': fields.char('Delay Close', size=20, readonly=True),
-- }
-- _order = 'stage_id, section_id, categ_id'
--
++ 'company_id': fields.many2one('res.company','Company',readonly=True),
++ }
++ _order = 'name desc, user_id'
def init(self, cr):
-- tools.sql.drop_view_if_exists(cr, "report_crm_case_section_categ_stage")
++ tools.drop_view_if_exists(cr, 'report_crm_case')
cr.execute("""
-- create view report_crm_case_section_categ_stage as (
++ create or replace view report_crm_case as (
select
min(c.id) as id,
-- to_char(c.create_date,'YYYY') as name,
++ 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.user_id,
c.section_id,
-- count(*) as nbr,
-- to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
++ c.company_id,
++ count(*) as nbr
from
crm_case 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)""")
++ group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.state, c.user_id,c.section_id,c.company_id
++ )""")
++report_crm_case()
--report_crm_case_section_categ_stage()
--
--class report_crm_case_section_categ_categ2(osv.osv):
-- _name = "report.crm.case.section.categ.categ2"
-- _description = "Cases by section, Category and Category2"
++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"
_auto = False
-- _columns = {
-- 'name': fields.char('Year',size=64,required=False, 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),
-- 'user_id':fields.many2one('res.users', 'User', readonly=True),
-- 'categ_id':fields.many2one('crm.case.categ', 'Category', readonly=True),
-- 'category2_id':fields.many2one('crm.case.category2', 'Type', readonly=True),
-- 'section_id':fields.many2one('crm.case.section', 'Section', readonly=True),
-- 'stage_id':fields.many2one('crm.case.stage', 'Stage', readonly=True),
-- 'nbr': fields.integer('# of Cases', readonly=True),
-- 'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True),
-- 'delay_close': fields.char('Delay Close', size=20, readonly=True),
-- }
-- _order = 'section_id, categ_id, category2_id'
--
++ _columns = {
++ 'date_deadline': fields.datetime('Deadline', readonly=True),
++ 'name': fields.char('Description', size=64, readonly=True),
++ 'user_id': fields.many2one('res.users', 'Responsible', readonly=True),
++ 'state': fields.selection(AVAILABLE_STATES, 'Status', size=16, readonly=True),
++ 'create_date' : fields.datetime('Create Date', readonly=True)
++ }
++ _order = 'create_date'
++
def init(self, cr):
-- tools.sql.drop_view_if_exists(cr, "report_crm_case_section_categ_categ2")
-- cr.execute("""
-- create view report_crm_case_section_categ_categ2 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.category2_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_case c
-- where c.categ_id is not null AND c.category2_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.category2_id, c.state, c.stage_id, c.section_id)""")
++ cr.execute("""create or replace view report_crm_case_service_dashboard as (
++ select
++ cse.id as id, cse.date_deadline as date_deadline,
++ cse.name as name, cse.user_id as user_id,
++ cse.state as state,
++ cse.create_date as create_date
++ from
++ crm_case cse
++ where
++ (cse.state='done')
++ OR
++
++ ((to_date(to_char(cse.create_date, 'YYYY-MM-dd'),'YYYY-MM-dd') <= CURRENT_DATE)
++ AND
++ (to_date(to_char(cse.create_date, 'YYYY-MM-dd'),'YYYY-MM-dd') > (CURRENT_DATE-15))
++ AND
++ cse.state='open')
++ )""")
++report_crm_case_service_dashboard()
++
--report_crm_case_section_categ_categ2()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
--- /dev/null
--- /dev/null
++from osv import fields,osv
++import tools
++
++class report_crm_claim(osv.osv):
++ _name = "report.crm.claim"
++ _auto = False
++ _inherit = "report.crm.case"
++ _columns = {
++ 'delay_close': fields.char('Delay to close', size=20, readonly=True),
++ 'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.claim')]", readonly=True),
++ 'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.claim')]",readonly=True),
++ 'partner_id': fields.many2one('res.partner', 'Partner',readonly=True),
++ 'company_id': fields.many2one('res.company','Company',readonly=True),
++ }
++ def init(self, cr):
++ tools.drop_view_if_exists(cr, 'report_crm_claim')
++ cr.execute("""
++ create or replace view report_crm_claim as (
++ select
++ min(c.id) as id,
++ to_char(c.create_date, 'YYYY') as name,
++ to_char(c.create_date, 'MM') as month,
++ c.state,
++ c.user_id,
++ c.stage_id,
++ c.section_id,
++ c.partner_id,
++ c.company_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_claim 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,c.categ_id,c.partner_id,c.company_id
++ )""")
++report_crm_claim()
++
++# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
--- /dev/null
--- /dev/null
++<?xml version="1.0" encoding="utf-8"?>
++<openerp>
++ <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="Claims">
++ <field name="name" />
++ <field name="month"/>
++ <field name="section_id" />
++ <field name="user_id" />
++ <field name="company_id" />
++ <field name="partner_id" />
++ <field name="nbr" string="#Claim"/>
++ <field name="delay_close"/>
++ <field name="state" invisible="1"/>
++ <field name="stage_id" invisible="1"/>
++ <field name="categ_id" invisible="1"/>
++ </tree>
++ </field>
++ </record>
++ <record id="view_crm_claim_form" model="ir.ui.view">
++ <field name="name">report.crm.claim.form</field>
++ <field name="model">report.crm.claim</field>
++ <field name="inherit_id" ref="view_crm_case_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_claim_graph" model="ir.ui.view">
++ <field name="name">report.crm.claim.graph</field>
++ <field name="model">report.crm.claim</field>
++ <field name="type">graph</field>
++ <field name="arch" type="xml">
++ <graph orientation="horizontal" string="Claims" type="bar">
++ <field name="state"/>
++ <field name="nbr" operator="+"/>
++ <field group="True" name="user_id"/>
++ </graph>
++ </field>
++ </record>
++
++ <record id="view_crm_claim_filter" model="ir.ui.view">
++ <field name="name">report.crm.claim.select</field>
++ <field name="model">report.crm.claim</field>
++ <field name="inherit_id" ref="view_crm_case_filter"/>
++ <field name="type">search</field>
++ <field name="arch" type="xml">
++ <xpath expr='//search[@string="Search"]/group[@string="Group By..."]/filter[@string="State"]' position='after'>
++ <filter string="Stage" icon="terp-sale" domain="[]" context="{'group_by':'stage_id'}"/>
++ </xpath>
++ </field>
++ </record>
++
++
++ <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">tree,graph</field>
++ <field name="view_id" ref="view_report_crm_claim_tree"/>
++ <field name="search_view_id" ref="view_crm_claim_filter"/>
++
++ </record>
++
++ <record model="ir.actions.act_window.view" id="action_report_crm_claim_tree">
++ <field name="sequence" eval="1"/>
++ <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"/>
++ </record>
++
++ <record model="ir.actions.act_window.view" id="action_report_crm_claim_graph">
++ <field name="sequence" eval="2"/>
++ <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="Claims" id="menu_crm_claim_tree" action="action_report_crm_claim" parent="base.next_id_64"/>
++
++
++ </data>
++</openerp>
--- /dev/null
--- /dev/null
++from osv import fields,osv
++import tools
++
++class report_crm_fundraising(osv.osv):
++ _name = "report.crm.fundraising"
++ _auto = False
++ _inherit = "report.crm.case"
++ _columns = {
++ 'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.fundraising')]"),
++ '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),
++ 'partner_id': fields.many2one('res.partner', 'Partner'),
++ 'company_id': fields.many2one('res.company','Company'),
++ }
++ def init(self, cr):
++ tools.drop_view_if_exists(cr, 'report_crm_fundraising')
++ cr.execute("""
++ create or replace view report_crm_fundraising as (
++ select
++ min(c.id) as id,
++ to_char(c.create_date, 'YYYY') as name,
++ to_char(c.create_date, 'MM') as month,
++ c.state,
++ c.user_id,
++ c.section_id,
++ c.categ_id,
++ c.company_id,
++ c.partner_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,
++ 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,c.categ_id,c.partner_id,c.company_id
++ )""")
++report_crm_fundraising()
++# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
--- /dev/null
--- /dev/null
++<?xml version="1.0" encoding="utf-8"?>
++<openerp>
++ <data>
++ <!--
++ Fundraising by user and section
++ -->
++
++ <record id="view_crm_fundraising_tree" model="ir.ui.view">
++ <field name="name">report.crm.fundraising.tree</field>
++ <field name="model">report.crm.fundraising</field>
++ <field name="type">tree</field>
++ <field name="arch" type="xml">
++ <tree string="Fundraising">
++ <field name="name" />
++ <field name="month"/>
++ <field name="section_id" />
++ <field name="user_id" />
++ <field name="company_id" />
++ <field name="partner_id" />
++ <field name="nbr" string="#Fundraising"/>
++ <field name="amount_revenue" sum="Total Revenue"/>
++ <field name="probability"/>
++ <field name="amount_revenue_prob"/>
++ <field name="delay_close"/>
++ <field name="state" invisible="1"/>
++ <field name="categ_id" invisible="1"/>
++ </tree>
++ </field>
++
++ </record>
++ <record id="view_crm_fundraising_form" model="ir.ui.view">
++ <field name="name">report.crm.fundraising.form</field>
++ <field name="model">report.crm.fundraising</field>
++ <field name="inherit_id" ref="view_crm_case_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_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" type="bar">
++ <field name="state"/>
++ <field name="nbr" operator="+"/>
++ <field group="True" name="user_id"/>
++ </graph>
++ </field>
++ </record>
++
++ <record id="view_crm_fundraising_filter" model="ir.ui.view">
++ <field name="name">report.crm.fundraising.select</field>
++ <field name="model">report.crm.fundraising</field>
++ <field name="inherit_id" ref="view_crm_case_filter"/>
++ <field name="type">search</field>
++ <field name="arch" type="xml">
++ <field name="user_id" position="before">
++ </field>
++ </field>
++ </record>
++
++ <record id="action_report_crm_fundraising" model="ir.actions.act_window">
++ <field name="name">Fundraising</field>
++ <field name="res_model">report.crm.fundraising</field>
++ <field name="view_type">form</field>
++ <field name="view_mode">tree,graph</field>
++ <field name="view_id" ref="view_crm_fundraising_tree"/>
++ <field name="search_view_id" ref="view_crm_fundraising_filter"/>
++ </record>
++
++
++ <record model="ir.actions.act_window.view" id="action_report_crm_fundrising_tree">
++ <field name="sequence" eval="1"/>
++ <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>
++
++ <record model="ir.actions.act_window.view" id="action_report_crm_fundrising_graph">
++ <field name="sequence" eval="2"/>
++ <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="base.next_id_64"/>
++
++ </data>
++</openerp>
--- /dev/null
--- /dev/null
++from osv import fields,osv
++import tools
++
++class report_crm_lead(osv.osv):
++ _name = "report.crm.lead"
++ _auto = False
++ _inherit = "report.crm.case"
++ _columns = {
++ '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.lead')]" ,readonly=True),
++ 'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]", readonly=True),
++ 'partner_id': fields.many2one('res.partner', 'Partner' ,readonly=True),
++ 'company_id': fields.many2one('res.company','Company',readonly=True),
++ }
++ def init(self, cr):
++ tools.drop_view_if_exists(cr, 'report_crm_lead')
++ cr.execute("""
++ create or replace view report_crm_lead as (
++ select
++ min(c.id) as id,
++ to_char(c.create_date, 'YYYY') as name,
++ to_char(c.create_date, 'MM') as month,
++ c.state,
++ c.user_id,
++ c.stage_id,
++ c.company_id,
++ c.section_id,
++ c.categ_id,
++ c.partner_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,categ_id,c.partner_id,c.company_id
++ )""")
++report_crm_lead()
++# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
--- /dev/null
--- /dev/null
++<?xml version="1.0" encoding="utf-8"?>
++<openerp>
++ <data>
++ <!--
++ Leads by user and section
++ -->
++
++ <record id="view_crm_lead_tree" model="ir.ui.view">
++ <field name="name">report.crm.lead.tree</field>
++ <field name="model">report.crm.lead</field>
++ <field name="type">tree</field>
++ <field name="arch" type="xml">
++ <tree string="Leads">
++ <field name="name" />
++ <field name="month"/>
++ <field name="section_id" />
++ <field name="user_id" />
++ <field name="company_id" />
++ <field name="partner_id" />
++ <field name="nbr" string="#Leads"/>
++ <field name="delay_close"/>
++ <field name="state" invisible="1"/>
++ <field name="stage_id" invisible="1"/>
++ <field name="categ_id" invisible="1"/>
++ </tree>
++ </field>
++ </record>
++ <record id="view_crm_lead_form" model="ir.ui.view">
++ <field name="name">report.crm.lead.form</field>
++ <field name="model">report.crm.lead</field>
++ <field name="inherit_id" ref="view_crm_case_form"/>
++ <field name="type">form</field>
++ <field name="arch" type="xml">
++ <field name="nbr" position="after">
++ <field name="delay_close"/>
++ <field name="stage_id"/>
++ </field>
++ </field>
++ </record>
++
++ <record id="view_crm_lead_graph" model="ir.ui.view">
++ <field name="name">report.crm.lead.graph</field>
++ <field name="model">report.crm.lead</field>
++ <field name="type">graph</field>
++ <field name="arch" type="xml">
++ <graph orientation="horizontal" string="Leads" type="bar">
++ <field name="state"/>
++ <field name="nbr" operator="+"/>
++ <field group="True" name="user_id"/>
++ </graph>
++ </field>
++ </record>
++
++ <record id="view_crm_lead_filter" model="ir.ui.view">
++ <field name="name">report.crm.lead.select</field>
++ <field name="model">report.crm.lead</field>
++ <field name="inherit_id" ref="view_crm_case_filter"/>
++ <field name="type">search</field>
++ <field name="arch" type="xml">
++ <xpath expr='//search[@string="Search"]/group[@string="Group By..."]/filter[@string="State"]' position='after'>
++ <filter string="Stage" icon="terp-sale" domain="[]" context="{'group_by':'stage_id'}"/>
++ </xpath>
++ </field>
++ </record>
++
++
++ <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="view_mode">tree,graph</field>
++ <field name="search_view_id" ref="view_crm_lead_filter"/>
++
++ </record>
++
++ <record model="ir.actions.act_window.view" id="action_report_crm_lead_tree">
++ <field name="sequence" eval="1"/>
++ <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"/>
++ </record>
++
++ <record model="ir.actions.act_window.view" id="action_report_crm_lead_graph">
++ <field name="sequence" eval="2"/>
++ <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>
++
++ <menuitem name="Leads" id="menu_crm_leads_tree" parent="base.next_id_64" action="action_report_crm_lead"/>
++ </data>
++</openerp>
--- /dev/null
--- /dev/null
++from osv import fields,osv
++import tools
++
++class report_crm_opportunity(osv.osv):
++ _name = "report.crm.opportunity"
++ _auto = False
++ _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')]", readonly=True),
++ 'stage_id':fields.many2one('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]", readonly=True),
++ 'partner_id': fields.many2one('res.partner', 'Partner',readonly=True),
++ 'company_id': fields.many2one('res.company', 'Company',readonly=True),
++ }
++ def init(self, cr):
++ tools.drop_view_if_exists(cr, 'report_crm_opportunity')
++ cr.execute("""
++ create or replace view report_crm_opportunity as (
++ select
++ min(c.id) as id,
++ to_char(c.create_date, 'YYYY') as name,
++ to_char(c.create_date, 'MM') as month,
++ c.state,
++ c.user_id,
++ c.section_id,
++ c.categ_id,
++ c.stage_id,
++ c.partner_id,
++ c.company_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)/100.0)::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_opportunity 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,c.categ_id,c.partner_id,company_id
++ )""")
++report_crm_opportunity()
++# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
--- /dev/null
--- /dev/null
++<?xml version="1.0" encoding="utf-8"?>
++<openerp>
++ <data>
++ <!--
++ Opportunities by user and section
++ -->
++
++ <record id="view_crm_opportunity_tree" model="ir.ui.view">
++ <field name="name">report.crm.opportunity.tree</field>
++ <field name="model">report.crm.opportunity</field>
++ <field name="type">tree</field>
++ <field name="arch" type="xml">
++ <tree string="Opportunities">
++ <field name="name" />
++ <field name="month"/>
++ <field name="section_id" />
++ <field name="user_id" />
++ <field name="company_id"/>
++ <field name="partner_id"/>
++ <field name="nbr" string="#Opportunities"/>
++ <field name="amount_revenue" sum="Total Revenue"/>
++ <field name="probability" widget="progressbar"/>
++ <field name="amount_revenue_prob"/>
++ <field name="delay_close"/>
++ <field name="state" invisible="1"/>
++ <field name="stage_id" invisible="1"/>
++ <field name="categ_id" invisible="1"/>
++ </tree>
++ </field>
++ </record>
++ <record id="view_crm_opportunity_form" model="ir.ui.view">
++ <field name="name">report.crm.opportunity.form</field>
++ <field name="model">report.crm.opportunity</field>
++ <field name="inherit_id" ref="view_crm_case_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_opportunity_graph" model="ir.ui.view">
++ <field name="name">report.crm.opportunity.graph</field>
++ <field name="model">report.crm.opportunity</field>
++ <field name="type">graph</field>
++ <field name="arch" type="xml">
++ <graph orientation="horizontal" string="Opportunity" type="bar">
++ <field name="state"/>
++ <field name="nbr" operator="+"/>
++ <field group="True" name="user_id"/>
++ </graph>
++ </field>
++ </record>
++
++ <record id="view_crm_opportunity_filter" model="ir.ui.view">
++ <field name="name">report.crm.opportunity.select</field>
++ <field name="model">report.crm.opportunity</field>
++ <field name="inherit_id" ref="view_crm_case_filter"/>
++ <field name="type">search</field>
++ <field name="arch" type="xml">
++ <xpath expr='//search[@string="Search"]/group[@string="Group By..."]/filter[@string="State"]' position='after'>
++ <filter string="Stage" icon="terp-sale" domain="[]" context="{'group_by':'stage_id'}"/>
++ <separator orientation="vertical"/>
++ <filter string="Partner" icon="terp-partner" domain="[]" context="{'group_by':'partner_id'}"/>
++ </xpath>
++ </field>
++ </record>
++
++ <record id="action_report_crm_opportunity" model="ir.actions.act_window">
++ <field name="name">Opportunities</field>
++ <field name="res_model">report.crm.opportunity</field>
++ <field name="view_type">form</field>
++ <field name="view_mode">tree,graph</field>
++ <field name="search_view_id" ref="view_crm_opportunity_filter"/>
++ </record>
++ <record model="ir.actions.act_window.view" id="action_report_crm_opportunity_tree">
++ <field name="sequence" eval="1"/>
++ <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"/>
++ </record>
++ <record model="ir.actions.act_window.view" id="action_report_crm_opportunity_graph">
++ <field name="sequence" eval="2"/>
++ <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="Opportunities" action="action_report_crm_opportunity" id="menu_crm_opportunity_tree" parent="base.next_id_64"/>
++ </data>
++</openerp>
--- /dev/null
--- /dev/null
++from osv import fields,osv
++import tools
++
++class report_crm_phonecall(osv.osv):
++ _name = "report.crm.phonecall"
++ _description = "Phone calls by user and section"
++ _auto = False
++ _inherit = "report.crm.case"
++ _columns = {
++ '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.phonecall')]"),
++ 'partner_id': fields.many2one('res.partner', 'Partner' ,readonly=True),
++ 'company_id': fields.many2one('res.company','Company',readonly=True),
++ }
++ def init(self, cr):
++ tools.drop_view_if_exists(cr, 'report_crm_phonecall')
++ cr.execute("""
++ create or replace view report_crm_phonecall as (
++ select
++ min(c.id) as id,
++ to_char(c.create_date, 'YYYY') as name,
++ to_char(c.create_date, 'MM') as month,
++ c.state,
++ c.user_id,
++ c.section_id,
++ c.categ_id,
++ c.partner_id,
++ c.company_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_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,c.partner_id,c.company_id
++ )""")
++report_crm_phonecall()
++# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
--- /dev/null
--- /dev/null
++<?xml version="1.0" encoding="utf-8"?>
++<openerp>
++ <data>
++ <!--
++ Phone calls by user and section
++ -->
++
++ <record id="view_crm_phonecall_tree" model="ir.ui.view">
++ <field name="name">report.crm.phonecall.tree</field>
++ <field name="model">report.crm.phonecall</field>
++ <field name="type">tree</field>
++ <field name="arch" type="xml">
++ <tree string="Phone calls">
++ <field name="name" />
++ <field name="month"/>
++ <field name="section_id" />
++ <field name="user_id" />
++ <field name="company_id"/>
++ <field name="partner_id" />
++ <field name="nbr" string="#Phone calls" />
++ <field name="delay_close"/>
++ <field name="state" invisible="1"/>
++ <field name="categ_id" invisible="1"/>
++ </tree>
++ </field>
++ </record>
++ <record id="view_crm_phonecall_form" model="ir.ui.view">
++ <field name="name">report.crm.phonecall.form</field>
++ <field name="model">report.crm.phonecall</field>
++ <field name="inherit_id" ref="view_crm_case_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_graph" model="ir.ui.view">
++ <field name="name">report.crm.phonecall.graph</field>
++ <field name="model">report.crm.phonecall</field>
++ <field name="type">graph</field>
++ <field name="arch" type="xml">
++ <graph orientation="horizontal" string="Phone calls by User and Section" type="bar">
++ <field name="state"/>
++ <field name="nbr" operator="+"/>
++ <field group="True" name="user_id"/>
++ </graph>
++ </field>
++ </record>
++ <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="inherit_id" ref="view_crm_case_filter"/>
++ <field name="type">search</field>
++ <field name="arch" type="xml">
++ <field name="user_id" position="before">
++ </field>
++ </field>
++ </record>
++
++ <record id="action_report_crm_phonecall" model="ir.actions.act_window">
++ <field name="name">Phone Calls</field>
++ <field name="res_model">report.crm.phonecall</field>
++ <field name="view_type">form</field>
++ <field name="view_mode">tree,graph</field>
++ <field name="view_id" ref="view_crm_phonecall_tree"/>
++ <field name="search_view_id" ref="view_crm_phonecall_filter"/>
++ </record>
++
++ <record model="ir.actions.act_window.view" id="action_report_crm_phonecall_tree">
++ <field name="sequence" eval="1"/>
++ <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>
++
++ <record model="ir.actions.act_window.view" id="action_report_crm_phonecall_graph">
++ <field name="sequence" eval="2"/>
++ <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="base.next_id_64"/>
++
++ </data>
++</openerp>
--- /dev/null
--- /dev/null
++<?xml version="1.0" encoding="utf-8"?>
++<openerp>
++ <data>
++
++ <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">
++ <field name="name" />
++ <field name="month"/>
++ <field name="user_id"/>
++ <field name="company_id"/>
++ <field name="section_id"/>
++ <field name="nbr"/>
++ <field name="state"/>
++ </tree>
++ </field>
++ </record>
++ <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">
++ <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"/>
++ </form>
++ </field>
++ </record>
++
++ <record id="view_crm_case_graph" model="ir.ui.view">
++ <field name="name">report.crm.case.graph</field>
++ <field name="model">report.crm.case</field>
++ <field name="type">graph</field>
++ <field name="arch" type="xml">
++ <graph orientation="horizontal" string="Cases by User and Section" type="bar">
++ <field name="state"/>
++ <field name="nbr" operator="+"/>
++ <field group="True" name="user_id"/>
++ </graph>
++ </field>
++ </record>
++
++ <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">
++ <group col="16" colspan="8">
++ <filter string="This Year" icon="terp-hr" domain="[('name','=',time.localtime()[0])]" default="1" />
++ <filter string="This Month" icon="terp-hr" domain="[('month','=',time.strftime('%%m'))]" default="1"/>
++ <separator orientation="vertical"/>
++ <filter string="Current" icon="terp-hr" domain="[('state','in',('open','draft'))]"/>
++ <filter string="Won" icon="terp-hr" domain="[('state','=','done')]"/>
++ <filter string="Lost" icon="terp-hr" domain="[('state','=','cancel')]"/>
++ <separator orientation="vertical"/>
++ <field name="section_id" default="context.get('section_id', False)" widget="selection"
++ context="{'invisible_section': False}">
++ <filter icon="terp-crm"
++ context="{'invisible_section': False}"
++ domain="[('section_id.user_id','=',uid)]"
++ help="My section"/>
++ </field>
++ <field name="user_id" widget="selection"/>
++ </group>
++ <newline/>
++ <group expand="1" string="Group By..." colspan="4" col="8">
++ <filter string="User" icon="terp-sale" domain="[]" context="{'group_by':'user_id'}" default="1" />
++ <filter string="Company" icon="terp-sale" domain="[]" context="{'group_by':'company_id'}"/>
++ <filter string="Section" icon="terp-sale" domain="[]" context="{'group_by':'section_id'}"/>
++ <separator orientation="vertical"/>
++ <filter string="State" icon="terp-sale" domain="[]" context="{'group_by':'state'}"/>
++ <filter string="Category" icon="terp-sale" domain="[]" context="{'group_by':'categ_id'}"/>
++ <separator orientation="vertical"/>
++ <filter string="Month" icon="terp-sale" domain="[]" context="{'group_by':'month'}"/>
++ <filter string="Year" icon="terp-sale" domain="[]" context="{'group_by':'name'}"/>
++
++ </group>
++ </search>
++ </field>
++ </record>
++ <menuitem id="base.next_id_64" name="Reporting" parent="base.menu_base_partner" sequence="8"/>
++
++
++ <record id="action_report_crm_case_tree" model="ir.actions.act_window">
++ <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_filter"/>
++ </record>
++ <!--<menuitem action="action_report_crm_case_user_tree" id="menu_crm_case_user_tree" parent="crm.next_id_52"/>
++-->
++ <!-- <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" 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" 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" src_model="crm.case.section"/>
++
++
++
++
++ <!-- Closed & Open CRM Case view for Random Activities dashboard -->
++
++ <record id="board_view_crm_case_open_dashboard_tree" model="ir.ui.view">
++ <field name="name">report.crm.case.service.dashboard.tree</field>
++ <field name="model">report.crm.case.service.dashboard</field>
++ <field name="type">tree</field>
++ <field name="arch" type="xml">
++ <tree string="CRM Cases">
++ <field name="create_date" select="1"/>
++ <field name="date" select="1"/>
++ <field name="date_deadline"/>
++ <field name="name" select="1"/>
++ <field name="user_id" select="2"/>
++ <field name="state" />
++ </tree>
++ </field>
++ </record>
++
++ <record id="board_view_crm_case_done_dashboard_tree" model="ir.ui.view">
++ <field name="name">report.crm.case.service.dashboard.tree</field>
++ <field name="model">report.crm.case.service.dashboard</field>
++ <field name="type">tree</field>
++ <field name="arch" type="xml">
++ <tree string="CRM Cases">
++ <field name="date"/>
++ <field name="name"/>
++ <field name="user_id" select="2"/>
++ <field name="state" />
++ </tree>
++ </field>
++ </record>
++
++ <record id="action_view_closed_crm_case_dashboard" model="ir.actions.act_window">
++ <field name="name">Closed CRM Cases Within Past 15 Days</field>
++ <field name="res_model">report.crm.case.service.dashboard</field>
++ <field name="view_type">form</field>
++ <field name="view_mode">tree,form</field>
++ <field name="view_id" ref="board_view_crm_case_done_dashboard_tree"/>
++ <field name="domain">[('state','=','done')]</field>
++ </record>
++
++ <record id="action_view_open_crm_case_dashboard" model="ir.actions.act_window">
++ <field name="name">Open CRM Cases Within Past 15 Days</field>
++ <field name="res_model">report.crm.case.service.dashboard</field>
++ <field name="view_type">form</field>
++ <field name="view_mode">tree,form</field>
++ <field name="view_id" ref="board_view_crm_case_open_dashboard_tree"/>
++ <field name="domain">[('state','=','open')]</field>
++ </record>
++
++ </data>
++</openerp>