[IMP]: crm: In crm Report file Apply format code + quality and dostring

bzr revid: ksa@tinyerp.co.in-20100318084613-mk90nka0qmwtnk57
This commit is contained in:
ksa (Open ERP) 2010-03-18 14:16:13 +05:30
parent 8017c327ea
commit 82d77f3024
18 changed files with 654 additions and 244 deletions

View File

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<report auto="False" id="crm_business_opportunities_report" keyword="client_print_multi" menu="True" model="crm.case" multi="True" name="crm.case" string="Business Opportunities"/>
<report auto="False" id="crm_business_opportunities_report"
keyword="client_print_multi" menu="True" model="crm.case"
multi="True" name="crm.case" string="Business Opportunities" />
</data>
</openerp>

View File

@ -1,11 +1,10 @@
<?xml version="1.0"?>
<openerp>
<data>
#
# Cases by section and category2 of case
#
<!-- <menuitem id="next_id_64" name="Reporting" parent="crm.menu_crm"-->
<!-- sequence="50"/>-->
<record model="ir.ui.view" id="view_crm_case_section_categ_tree">
<field name="name">CRM Report - Sections and Type(Tree)</field>
@ -161,7 +160,6 @@
<field name="view_mode">graph,tree</field>
<field name="search_view_id" ref="view_crm_case_section_stage_filter"/>
</record>
<!-- <menuitem parent="next_id_64" name="Cases by Section and Stage" action="action_report_crm_case_section_stage_tree" id="menu_crm_case_section_stage_tree"/>-->
#
# Cases by section, category and stage
@ -211,9 +209,13 @@
<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.localtime()[1])]" help="Cases by Section, Category and Stage for this month"/>
<separator orientation="vertical"/>
<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.localtime()[1])]"
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"/>
@ -240,7 +242,6 @@
<field name="view_mode">tree,graph</field>
<field name="search_view_id" ref="view_crm_case_section_categ_stage_filter"/>
</record>
<!-- <menuitem parent="next_id_64" name="Cases by Section, Category and Stage" action="action_report_crm_case_section_categ_stage_tree" id="menu_crm_case_section_categ_stage_tree"/>-->
#
# Cases by section, category and category2
@ -292,9 +293,13 @@
<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.localtime()[1])]" help="Cases by User for this month"/>
<separator orientation="vertical"/>
<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.localtime()[1])]"
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"/>
@ -321,6 +326,6 @@
<field name="view_mode">tree,graph</field>
<field name="search_view_id" ref="view_crm_case_section_categ_categ2_filter"/>
</record>
<!-- <menuitem parent="next_id_64" name="Cases by Section, Category and Type" action="action_report_crm_case_section_categ_categ2_tree" id="menu_crm_case_section_categ_categ2_tree"/>-->
</data>
</openerp>

View File

@ -4,8 +4,10 @@
<!-- <menuitem icon="terp-crm" id="menu_crm" name="CRM &amp; SRM"/>-->
<menuitem id="menu_crm_configuration" name="Cases" parent="base.menu_base_config" sequence="0"/>
<wizard id="wizard_crm_send_mail" model="crm.case.history" name="crm.send.mail" string="Send Mail" menu="False"/>
<wizard id="wizard_crm_new_send_mail" model="crm.case" name="crm.new.send.mail" string="Send New Mail" menu="False"/>
<wizard id="wizard_crm_send_mail" model="crm.case.history"
name="crm.send.mail" string="Send Mail" menu="False" />
<wizard id="wizard_crm_new_send_mail" model="crm.case"
name="crm.new.send.mail" string="Send New Mail" menu="False" />
<!-- Case Sections -->
<record id="crm_case_section_view_form" model="ir.ui.view">
@ -61,7 +63,7 @@
<field name="name"/>
<field name="probability"/>
<field name="section_id"/>
</tree>
</field>
</record>
@ -91,7 +93,7 @@
</record>
<menuitem id="menu_crm_case_stage" name="Stages" parent="crm.menu_crm_configuration"/>
<!-- Case Categories -->
<record id="crm_case_categ-view" model="ir.ui.view">
<field name="name">crm.case.categ.form</field>
@ -101,7 +103,7 @@
<form string="Case Category">
<field name="name" select="1"/>
<field name="section_id" select="1" widget="selection"/>
<field name="object_id" invisible="1" />
<field name="object_id" invisible="1" />
</form>
</field>
</record>
@ -112,7 +114,7 @@
<field name="arch" type="xml">
<tree string="Case Category">
<field name="name"/>
<field name="section_id"/>
<field name="section_id"/>
</tree>
</field>
</record>
@ -126,8 +128,8 @@
<menuitem id="menu_crm_case_categ" name="Categories" parent="crm.menu_crm_configuration"/>
<menuitem action="crm_case_section_act" id="menu_crm_case_section_act" parent="crm.menu_crm_configuration"/>
# ------------------------------------------------------
# Resource Type of case
# ------------------------------------------------------
@ -155,7 +157,7 @@
</form>
</field>
</record>
<record id="crm_case_resource_type_act" model="ir.actions.act_window">
<field name="name">Resource Type</field>
<field name="res_model">crm.case.resource.type</field>
@ -163,9 +165,9 @@
<field name="view_id" ref="crm_case_resource_type_tree"/>
</record>
<menuitem id="menu_crm_case_resource_type" name="Resource Type" parent="crm.menu_crm_configuration"/>
<!--<menuitem action="crm_case_resource_type_act" id="menu_crm_case_resource_act" parent="menu_crm_case_resource_type"/>-->
<!-- <menuitem id="next_id_52" name="All Cases" parent="crm.menu_crm" sequence="1"/>-->
<record id="crm_case_section_act_tree" model="ir.actions.act_window">
@ -176,8 +178,8 @@
<field name="view_id" ref="crm_case_section_view_tree"/>
</record>
<!-- <menuitem action="crm_case_section_act_tree" id="menu_crm_case_section_act_tree" parent="next_id_52"/>-->
<record id="view_crm_email_add_cc_wizard" model="ir.ui.view">
<field name="name">Add CC</field>
<field name="model">crm.email.add.cc</field>
@ -599,7 +601,7 @@
</field>
</field>
</record>
<record id="view_partners_form_crm1" model="ir.ui.view">
<field name="name">view.res.partner.form.crm.inherited1</field>
<field name="model">res.partner</field>
@ -612,7 +614,7 @@
</field>
</field>
</record>
<record id="view_partners_form_crm2" model="ir.ui.view">
<field name="name">view.res.partner.form.crm.inherited2</field>
<field name="model">res.partner</field>
@ -625,7 +627,7 @@
</field>
</field>
</record>
<record id="view_partners_form_crm3" model="ir.ui.view">
<field name="name">view.res.partner.form.crm.inherited3</field>
<field name="model">res.partner</field>

View File

@ -1,18 +1,54 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields,osv
import tools
class crm_claim_report(osv.osv):
""" CRM Claim Report"""
_name = "crm.claim.report"
_auto = False
_inherit = "crm.case.report"
_description = "CRM Claim Report"
_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),
'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):
"""
@param cr: the current row, from the database cursor,
Display Number of cases And Section Name """
tools.drop_view_if_exists(cr, 'crm_claim_report')
cr.execute("""
create or replace view crm_claim_report as (
@ -34,8 +70,11 @@ class crm_claim_report(osv.osv):
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
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
)""")
crm_claim_report()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<data>
<!-- CRM Claim Report Tree View -->
<record id="view_report_crm_claim_tree" model="ir.ui.view">
<field name="name">crm.claim.report.tree</field>
@ -22,6 +24,9 @@
</tree>
</field>
</record>
<!-- CRM Claim Report Form View -->
<record id="view_report_crm_claim_form" model="ir.ui.view">
<field name="name">crm.claim.report.form</field>
<field name="model">crm.claim.report</field>
@ -37,7 +42,9 @@
</field>
</field>
</record>
<!-- CRM Claim Report Graph View -->
<record id="view_report_crm_claim_graph" model="ir.ui.view">
<field name="name">crm.claim.report.graph</field>
<field name="model">crm.claim.report</field>
@ -51,18 +58,24 @@
</field>
</record>
<!-- CRM Claim Report Search View -->
<record id="view_report_crm_claim_filter" model="ir.ui.view">
<field name="name">crm.claim.report.select</field>
<field name="model">crm.claim.report</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>
<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>
<!-- CRM Claim Report Action -->
<record id="action_report_crm_claim" model="ir.actions.act_window">
<field name="name">Claims</field>
@ -73,24 +86,24 @@
<field name="search_view_id" ref="view_report_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>
<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_report_crm_claim_graph"/>
<field name="act_window_id" ref="action_report_crm_claim"/>
</record>
<menuitem name="Claims" id="menu_report_crm_claim_tree" action="action_report_crm_claim" parent="base.next_id_64"/>
</record>
<menuitem name="Claims" id="menu_report_crm_claim_tree"
action="action_report_crm_claim" parent="base.next_id_64" />
</data>
</data>
</openerp>

View File

@ -1,20 +1,53 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields,osv
import tools
class crm_fundraising_report(osv.osv):
"""CRM Fundraising Report"""
_name = "crm.fundraising.report"
_auto = False
_inherit = "crm.case.report"
_description = "CRM Fundraising Report"
_columns = {
'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.fundraising')]"),
'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'),
'partner_id': fields.many2one('res.partner', 'Partner'),
'company_id': fields.many2one('res.company', 'Company'),
}
def init(self, cr):
""" @param cr: the current row, from the database cursor
Display Number of cases and Average Probability """
tools.drop_view_if_exists(cr, 'crm_fundraising_report')
cr.execute("""
create or replace view crm_fundraising_report as (
@ -32,13 +65,16 @@ class crm_fundraising_report(osv.osv):
0 as avg_answers,
0.0 as perc_done,
0.0 as perc_cancel,
sum(planned_revenue) as amount_revenue,
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
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
)""")
crm_fundraising_report()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,9 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!--
Fundraising by user and section
-->
<!-- Fundraising by user and section Tree View-->
<record id="view_report_crm_fundraising_tree" model="ir.ui.view">
<field name="name">crm.fundraising.report.tree</field>
@ -15,7 +14,7 @@
<field name="month"/>
<field name="section_id" />
<field name="user_id" />
<field name="company_id" />
<field name="company_id" />
<field name="partner_id" />
<field name="nbr" string="#Fundraising"/>
<field name="amount_revenue" sum="Total Revenue"/>
@ -25,7 +24,9 @@
<field name="state" invisible="1"/>
<field name="categ_id" invisible="1"/>
</tree>
</field>
</field>
<!-- Fundraising by user and section Form View-->
</record>
<record id="view_report_crm_fundraising_form" model="ir.ui.view">
@ -42,7 +43,9 @@
</field>
</field>
</record>
<!-- Fundraising by user and section Graph View-->
<record id="view_report_crm_fundraising_graph" model="ir.ui.view">
<field name="name">crm.fundraising.report.graph</field>
<field name="model">crm.fundraising.report</field>
@ -56,6 +59,8 @@
</field>
</record>
<!-- Fundraising by user and section Search View-->
<record id="view_report_crm_fundraising_filter" model="ir.ui.view">
<field name="name">crm.fundraising.report.select</field>
<field name="model">crm.fundraising.report</field>
@ -66,7 +71,9 @@
</field>
</field>
</record>
<!-- Fundraising by user and section Action -->
<record id="action_report_crm_fundraising" model="ir.actions.act_window">
<field name="name">Fundraising</field>
<field name="res_model">crm.fundraising.report</field>
@ -75,22 +82,25 @@
<field name="view_id" ref="view_report_crm_fundraising_tree"/>
<field name="search_view_id" ref="view_report_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_report_crm_fundraising_tree"/>
<field name="act_window_id" ref="action_report_crm_fundraising"/>
</record>
</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_report_crm_fundraising_graph"/>
<field name="act_window_id" ref="action_report_crm_fundraising"/>
</record>
<menuitem name="Fundraising" action="action_report_crm_fundraising" id="menu_report_crm_fundraising_tree" parent="base.next_id_64"/>
</data>
</record>
<menuitem name="Fundraising"
action="action_report_crm_fundraising"
id="menu_report_crm_fundraising_tree" parent="base.next_id_64" />
</data>
</openerp>

View File

@ -18,23 +18,33 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields,osv
import tools
class crm_helpdesk_report(osv.osv):
""" Helpdesk report after Sales Services """
_name = "crm.helpdesk.report"
_description = "Helpdesk report after Sales Services"
_auto = False
_inherit = "crm.case.report"
_columns = {
'delay_close': fields.char('Delay to close', size=20, readonly=True),
'partner_id': fields.many2one('res.partner', 'Partner' ,readonly=True),
'company_id': fields.many2one('res.company','Company',readonly=True),
'partner_id': fields.many2one('res.partner', 'Partner' , readonly=True),
'company_id': fields.many2one('res.company', 'Company', readonly=True),
'date_deadline': fields.date('Deadline'),
'priority': fields.selection([('5','Lowest'),('4','Low'),('3','Normal'),('2','High'),('1','Highest')], 'Priority'),
'priority': fields.selection([('5', 'Lowest'), ('4', 'Low'), \
('3', 'Normal'), ('2', 'High'), ('1', 'Highest')], 'Priority'),
}
def init(self, cr):
"""@param cr: the current row, from the database cursor
Display Deadline ,Responsible user, partner ,Department """
tools.drop_view_if_exists(cr, 'crm_helpdesk_report')
cr.execute("""
create or replace view crm_helpdesk_report as (
@ -56,8 +66,11 @@ class crm_helpdesk_report(osv.osv):
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_helpdesk c
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.state, c.user_id,c.section_id,c.priority, c.partner_id,c.company_id,c.date_deadline
group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'),\
c.state, c.user_id,c.section_id,c.priority,\
c.partner_id,c.company_id,c.date_deadline
)""")
crm_helpdesk_report()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,9 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!--
Helpdesk report after Sales Services
-->
<!-- Helpdesk report after Sales Services Tree View -->
<record id="view_report_crm_helpdesk_tree" model="ir.ui.view">
<field name="name">crm.helpdesk.report.tree</field>
@ -25,6 +24,9 @@
</tree>
</field>
</record>
<!-- Helpdesk report after Sales Services Form View -->
<record id="view_report_crm_helpdesk_form" model="ir.ui.view">
<field name="name">crm.helpdesk.report.form</field>
<field name="model">crm.helpdesk.report</field>
@ -40,6 +42,8 @@
</field>
</record>
<!-- Helpdesk report after Sales Services Graph View -->
<record id="view_report_crm_helpdesk_graph" model="ir.ui.view">
<field name="name">crm.helpdesk.report.graph</field>
<field name="model">crm.helpdesk.report</field>
@ -53,6 +57,8 @@
</field>
</record>
<!-- Helpdesk report after Sales Services Search View -->
<record id="view_report_crm_helpdesk_filter" model="ir.ui.view">
<field name="name">crm.helpdesk.report.select</field>
<field name="model">crm.helpdesk.report</field>
@ -60,26 +66,46 @@
<field name="arch" type="xml">
<search string="Search">
<group col="16" colspan="9">
<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')]"/>
<filter string="Deadline" icon="terp-hr" domain="[('date_deadline','=',time.strftime('%%m/%%d/%%Y'))]"/>
<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="company_id" widget="selection">
<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')]" />
<filter string="Deadline" icon="terp-hr"
domain="[('date_deadline','=',time.strftime('%%m/%%d/%%Y'))]" />
<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="company_id" widget="selection">
<filter icon="terp-crm"
context="{'invisible_section': False}"
domain="[('section_id.user_id.company_id','=',uid)]"
help="My company"/>
</field>
<field name="user_id" widget="selection"/>
</group>
@ -88,36 +114,63 @@
<filter icon="terp-sale"
string="Lowest"
domain="[('priority','=','5')]"/>
<filter icon="terp-sale"
string="Low"
domain="[('priority','=','4')]"/>
<filter icon="terp-sale"
string="Normal"
domain="[('priority','=','3')]"/>
<filter icon="terp-sale"
string="High"
domain="[('priority','=','2')]"/>
<filter icon="terp-sale"
string="Highest"
domain="[('priority','=','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'}" 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="Partner" icon="terp-sale" domain="[]" context="{'group_by':'partner_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>
<!-- Helpdesk report after Sales Services Apply Group -->
<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="Partner" icon="terp-sale"
domain="[]"
context="{'group_by':'partner_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>
<!-- Helpdesk report after Sales Services Action -->
<record id="action_report_crm_helpdesk" model="ir.actions.act_window">
<field name="name">Helpdesk</field>
<field name="res_model">crm.helpdesk.report</field>
@ -141,8 +194,9 @@
<field name="act_window_id" ref="action_report_crm_helpdesk"/>
</record>
<menuitem name="Helpdesk" action="action_report_crm_helpdesk" id="menu_report_crm_helpdesks_tree" parent="base.next_id_64"/>
<menuitem name="Helpdesk" action="action_report_crm_helpdesk"
id="menu_report_crm_helpdesks_tree" parent="base.next_id_64" />
</data>
</data>
</openerp>

View File

@ -1,18 +1,50 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields,osv
import tools
class crm_lead_report(osv.osv):
""" CRM Lead Report """
_name = "crm.lead.report"
_auto = False
_inherit = "crm.case.report"
_description = "CRM Lead Report"
_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),
'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):
""" @param cr: the current row, from the database cursor
CRM Lead Report"""
tools.drop_view_if_exists(cr, 'crm_lead_report')
cr.execute("""
create or replace view crm_lead_report as (
@ -34,7 +66,10 @@ class crm_lead_report(osv.osv):
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
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
)""")
crm_lead_report()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,9 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!--
Leads by user and section
-->
<!-- Leads by user and section Tree View -->
<record id="view_report_crm_lead_tree" model="ir.ui.view">
<field name="name">crm.lead.report.tree</field>
@ -15,8 +14,8 @@
<field name="month"/>
<field name="section_id" />
<field name="user_id" />
<field name="company_id" />
<field name="partner_id" />
<field name="company_id" />
<field name="partner_id" />
<field name="nbr" string="#Leads"/>
<field name="delay_close"/>
<field name="state" invisible="1"/>
@ -25,6 +24,9 @@
</tree>
</field>
</record>
<!-- Leads by user and section Form View -->
<record id="view_report_crm_lead_form" model="ir.ui.view">
<field name="name">crm.lead.report.form</field>
<field name="model">crm.lead.report</field>
@ -37,7 +39,9 @@
</field>
</field>
</record>
<!-- Leads by user and section Graph View -->
<record id="view_report_crm_lead_graph" model="ir.ui.view">
<field name="name">crm.lead.report.graph</field>
<field name="model">crm.lead.report</field>
@ -51,42 +55,50 @@
</field>
</record>
<!-- Leads by user and section Search View -->
<record id="view_report_crm_lead_filter" model="ir.ui.view">
<field name="name">crm.lead.report.select</field>
<field name="model">crm.lead.report</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>
<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>
<!-- Leads by user and section Action -->
<record id="action_report_crm_lead" model="ir.actions.act_window">
<field name="name">Leads</field>
<field name="res_model">crm.lead.report</field>
<field name="view_type">form</field>
<field name="view_mode">tree,graph</field>
<field name="search_view_id" ref="view_report_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_report_crm_lead_tree"/>
<field name="act_window_id" ref="action_report_crm_lead"/>
</record>
</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_report_crm_lead_graph"/>
<field name="act_window_id" ref="action_report_crm_lead"/>
</record>
</record>
<menuitem name="Leads" id="menu_report_crm_leads_tree" parent="base.next_id_64" action="action_report_crm_lead"/>
</data>
<menuitem name="Leads" id="menu_report_crm_leads_tree"
parent="base.next_id_64" action="action_report_crm_lead" />
</data>
</openerp>

View File

@ -1,23 +1,56 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields,osv
import tools
class crm_opportunity_report(osv.osv):
_name = "crm.opportunity.report"
""" CRM Opportunity Report """
_name = "crm.opportunity.report"
_auto = False
_inherit = "crm.case.report"
_inherit = "crm.case.report"
_description = "CRM Opportunity Report"
_columns = {
'probability': fields.float('Avg. Probability', readonly=True),
'amount_revenue': fields.float('Est.Revenue', 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),
'user_id':fields.many2one('res.users', 'User', 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),
'user_id':fields.many2one('res.users', 'User', readonly=True),
}
def init(self, cr):
""" @param cr: the current row, from the database cursor
Display Est.Revenue , Average Probability ,Est.Revenue Probabilit """
tools.drop_view_if_exists(cr, 'crm_opportunity_report')
cr.execute("""
create or replace view crm_opportunity_report as (
@ -36,13 +69,16 @@ class crm_opportunity_report(osv.osv):
0 as avg_answers,
0.0 as perc_done,
0.0 as perc_cancel,
sum(planned_revenue) as amount_revenue,
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
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
)""")
crm_opportunity_report()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,9 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!--
Opportunities by user and section
-->
<!-- Opportunities by user and section Tree View -->
<record id="view_report_crm_opportunity_tree" model="ir.ui.view">
<field name="name">crm.opportunity.report.tree</field>
@ -16,7 +15,7 @@
<field name="section_id" />
<field name="user_id" />
<field name="company_id"/>
<field name="partner_id"/>
<field name="partner_id"/>
<field name="nbr" string="#Opportunities"/>
<field name="amount_revenue" sum="Total Revenue"/>
<field name="probability" widget="progressbar"/>
@ -26,8 +25,11 @@
<field name="stage_id" invisible="1"/>
<field name="categ_id" invisible="1"/>
</tree>
</field>
</field>
</record>
<!-- Opportunities by user and section Form View -->
<record id="view_report_crm_opportunity_form" model="ir.ui.view">
<field name="name">crm.opportunity.report.form</field>
<field name="model">crm.opportunity.report</field>
@ -43,7 +45,9 @@
</field>
</field>
</record>
<!-- Opportunities by user and section Graph View -->
<record id="view_report_crm_opportunity_graph" model="ir.ui.view">
<field name="name">crm.opportunity.report.graph</field>
<field name="model">crm.opportunity.report</field>
@ -57,20 +61,28 @@
</field>
</record>
<!-- Opportunities by user and section Search View -->
<record id="view_report_crm_opportunity_filter" model="ir.ui.view">
<field name="name">crm.opportunity.report.select</field>
<field name="model">crm.opportunity.report</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>
<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>
<!-- Opportunities by user and section Action -->
<record id="action_report_crm_opportunity" model="ir.actions.act_window">
<field name="name">Opportunities</field>
<field name="res_model">crm.opportunity.report</field>
@ -83,14 +95,17 @@
<field name="view_mode">tree</field>
<field name="view_id" ref="view_report_crm_opportunity_tree"/>
<field name="act_window_id" ref="action_report_crm_opportunity"/>
</record>
</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_report_crm_opportunity_graph"/>
<field name="act_window_id" ref="action_report_crm_opportunity"/>
</record>
</record>
<menuitem name="Opportunities" action="action_report_crm_opportunity" id="menu_report_crm_opportunity_tree" parent="base.next_id_64"/>
</data>
<menuitem name="Opportunities"
action="action_report_crm_opportunity"
id="menu_report_crm_opportunity_tree" parent="base.next_id_64" />
</data>
</openerp>

View File

@ -1,18 +1,49 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields,osv
import tools
class crm_phonecall_report(osv.osv):
""" Phone calls by user and section """
_name = "crm.phonecall.report"
_description = "Phone calls by user and section"
_auto = False
_inherit = "crm.case.report"
_columns = {
_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),
'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):
""" @param cr: the current row, from the database cursor,
Phone Calls By User And Section """
tools.drop_view_if_exists(cr, 'crm_phonecall_report')
cr.execute("""
create or replace view crm_phonecall_report as (
@ -26,14 +57,17 @@ class crm_phonecall_report(osv.osv):
c.categ_id,
c.partner_id,
c.company_id,
count(*) as nbr,
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.state, c.user_id,c.section_id, c.categ_id,c.partner_id,c.company_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.partner_id,c.company_id
)""")
crm_phonecall_report()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,9 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!--
Phone calls by user and section
-->
<!-- Phone calls by user and section Tree View -->
<record id="view_report_crm_phonecall_tree" model="ir.ui.view">
<field name="name">crm.phonecall.report.tree</field>
@ -20,10 +19,13 @@
<field name="nbr" string="#Phone calls" />
<field name="delay_close"/>
<field name="state" invisible="1"/>
<field name="categ_id" invisible="1"/>
<field name="categ_id" invisible="1"/>
</tree>
</field>
</record>
<!-- Phone calls by user and section Form View -->
<record id="view_report_crm_phonecall_form" model="ir.ui.view">
<field name="name">crm.phonecall.report.form</field>
<field name="model">crm.phonecall.report</field>
@ -38,7 +40,9 @@
</field>
</field>
</record>
<!-- Phone calls by user and section Graph View -->
<record id="view_report_crm_phonecall_graph" model="ir.ui.view">
<field name="name">crm.phonecall.report.graph</field>
<field name="model">crm.phonecall.report</field>
@ -50,7 +54,10 @@
<field group="True" name="user_id"/>
</graph>
</field>
</record>
</record>
<!-- Phone calls by user and section Search View -->
<record id="view_report_crm_phonecall_filter" model="ir.ui.view">
<field name="name">crm.phonecall.report.select</field>
<field name="model">crm.phonecall.report</field>
@ -60,8 +67,10 @@
<field name="user_id" position="before">
</field>
</field>
</record>
</record>
<!-- Phone calls by user and section Action -->
<record id="action_report_crm_phonecall" model="ir.actions.act_window">
<field name="name">Phone Calls</field>
<field name="res_model">crm.phonecall.report</field>
@ -70,22 +79,24 @@
<field name="view_id" ref="view_report_crm_phonecall_tree"/>
<field name="search_view_id" ref="view_report_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_report_crm_phonecall_tree"/>
<field name="act_window_id" ref="action_report_crm_phonecall"/>
</record>
</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_report_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_report_crm_phonecalls_tree" parent="base.next_id_64"/>
</data>
</record>
<menuitem name="Phone Calls"
action="action_report_crm_phonecall"
id="menu_report_crm_phonecalls_tree" parent="base.next_id_64" />
</data>
</openerp>

View File

@ -19,7 +19,7 @@
#
##############################################################################
from osv import fields,osv
from osv import fields, osv
import tools
AVAILABLE_STATES = [
@ -31,22 +31,31 @@ AVAILABLE_STATES = [
]
class crm_case_report(osv.osv):
""" Cases and section """
_name = "crm.case.report"
_description = "Cases and section"
_auto = False
def _get_data(self, cr, uid, ids, field_name, arg, context={}):
""" @param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of case and section Datas IDs
@param context: A standard dictionary for contextual values """
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))
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
perc_state = (state_cases / float(case.nbr)) * 100
res[case.id] = perc_state
else:
model_name = self._name.split('report.')
@ -55,29 +64,39 @@ class crm_case_report(osv.osv):
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)
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
res[case.id] = avg_ans
return res
_columns = {
'name': fields.char('Year',size=64,required=False, readonly=True),
'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),
'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),
'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),
'company_id': fields.many2one('res.company','Company',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),
'company_id': fields.many2one('res.company', 'Company', readonly=True),
}
_order = 'name desc, user_id'
def init(self, cr):
""" @param cr: the current row, from the database cursor """
tools.drop_view_if_exists(cr, 'crm_case_report')
cr.execute("""
create or replace view crm_case_report as (
@ -92,24 +111,34 @@ class crm_case_report(osv.osv):
count(*) as nbr
from
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,c.company_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
)""")
crm_case_report()
class report_crm_case_service_dashboard(osv.osv):
""" Report of Closed and Open CRM Cases within past 15 days """
_name = "report.crm.case.service.dashboard"
_description = "Report of Closed and Open CRM Cases within past 15 days"
_auto = False
_columns = {
_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):
""" @param cr: the current row, from the database cursor """
cr.execute("""create or replace view report_crm_case_service_dashboard as (
select
cse.id as id, cse.date_deadline as date_deadline,
@ -128,6 +157,7 @@ class report_crm_case_service_dashboard(osv.osv):
AND
cse.state='open')
)""")
report_crm_case_service_dashboard()

View File

@ -2,6 +2,8 @@
<openerp>
<data>
<!-- CRM Case Report Tree View -->
<record id="view_crm_case_tree" model="ir.ui.view">
<field name="name">crm.case.report.tree</field>
<field name="model">crm.case.report</field>
@ -18,6 +20,9 @@
</tree>
</field>
</record>
<!-- CRM Case Report Form View -->
<record id="view_crm_case_form" model="ir.ui.view">
<field name="name">crm.case.report.form</field>
<field name="model">>crm.case.report</field>
@ -34,6 +39,8 @@
</field>
</record>
<!-- CRM Case Report Graph View -->
<record id="view_crm_case_graph" model="ir.ui.view">
<field name="name">crm.case.report</field>
<field name="model">crm.case.report</field>
@ -47,6 +54,8 @@
</field>
</record>
<!-- CRM Case Report Search View -->
<record id="view_crm_case_filter" model="ir.ui.view">
<field name="name">crm.case.report.select</field>
<field name="model">crm.case.report</field>
@ -54,48 +63,83 @@
<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="company_id" widget="selection">
<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="company_id" widget="selection">
<filter icon="terp-crm"
context="{'invisible_section': False}"
domain="[('section_id.user_id.company_id','=',uid)]"
help="My company"/>
</field>
<field name="user_id" select="1" widget="selection">
<filter icon="terp-crm" string="My Task" domain="[('user_id','=',uid)]" />
</field>
</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'}"/>
<filter string="User" icon="terp-sale"
domain="[]" context="{'group_by':'user_id'}"
default="1" />
</group>
<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"/>
<!-- CRM Case Report Action -->
<record id="action_report_crm_case_tree" model="ir.actions.act_window">
<field name="name">Cases</field>
@ -104,20 +148,22 @@
<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="crm.case.report" src_model="res.users"/>
<act_window domain="[('user_id', '=', active_id)]"
id="act_res_users_2_report_crm_case_user" name="Monthly cases"
res_model="crm.case.report" 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="crm.case.report" src_model="crm.case.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="crm.case.report"
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="crm.case.report" 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="crm.case.report"
src_model="crm.case.section" />
<!-- Closed & Open CRM Case view for Random Activities dashboard -->
<!-- Closed & Open CRM Case view for Random Activities dashboard Tree View -->
<record id="board_view_crm_case_open_dashboard_tree" model="ir.ui.view">
<field name="name">report.crm.case.service.dashboard.tree</field>
@ -147,6 +193,8 @@
</field>
</record>
<!-- Closed & Open CRM Case view for Random Activities dashboard Action -->
<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>

View File

@ -38,16 +38,28 @@ theme.use_color = 1
random.seed(0)
class external_pdf(render):
""" Generate External PDF """
def __init__(self, pdf):
render.__init__(self)
self.pdf = pdf
self.output_type='pdf'
self.output_type = 'pdf'
def _render(self):
return self.pdf
class report_custom(report_int):
""" Create Custom Report """
def create(self, cr, uid, ids, datas, context={}):
""" @param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks,
@param ids: List of IDs
@param context: A standard dictionary for contextual values """
assert len(ids), 'You should provide some ids!'
responsible_data = {}
responsible_names = {}
@ -55,7 +67,10 @@ class report_custom(report_int):
minbenef = 999999999999999999999
maxbenef = 0
cr.execute('select probability, planned_revenue, planned_cost, user_id, res_users.name as name from crm_case left join res_users on (crm_case.user_id=res_users.id) where crm_case.id =ANY(%s) order by user_id',(ids,))
cr.execute('select probability, planned_revenue, planned_cost, user_id,\
res_users.name as name from crm_case left join res_users on \
(crm_case.user_id=res_users.id) where crm_case.id =ANY(%s) order by user_id',(ids,))
res = cr.dictfetchall()
for row in res:
proba = row['probability'] or 0 / 100.0
@ -100,14 +115,14 @@ class report_custom(report_int):
#-echelle variable
pdf_string = StringIO.StringIO()
can = canvas.init(fname=pdf_string, format='pdf')
can = canvas.init(fname = pdf_string, format = 'pdf')
chart_object.set_defaults(line_plot.T, line_style=None)
xaxis = axis.X(label=None, format="%d%%", tic_interval=20)
yaxis = axis.Y()
x_range_a, x_range_b = (0,100)
x_range_a, x_range_b = (0, 100)
y_range_a, y_range_b = (minbenef, maxbenef)
if y_range_a == 0.0:
y_range_a += 0.0001
@ -115,7 +130,7 @@ class report_custom(report_int):
ar = area.T(
size = (300,200),
y_grid_interval = 10000,
y_grid_style=None,
y_grid_style = None,
x_range = (x_range_a, x_range_b),
y_range = (y_range_a, y_range_b),
x_axis = xaxis,
@ -134,16 +149,17 @@ class report_custom(report_int):
# second graph (top right)
ar = area.T(legend = legend.T(),
size = (200,100),
loc=(100,250),
loc = (100,250),
x_grid_interval = lambda min, max: [40,60,80,100],
x_grid_style=line_style.gray70_dash1,
x_grid_style = line_style.gray70_dash1,
x_range = (33, 100),
x_axis = axis.X(label=None, minor_tic_interval=lambda min,max: [50, 70, 90], format=lambda x: ""),
y_axis=axis.Y(label="Planned amounts"))
x_axis = axis.X(label=None, minor_tic_interval = lambda min,max: [50, 70, 90],\
format=lambda x: ""),
y_axis = axis.Y(label="Planned amounts"))
bar_plot.fill_styles.reset();
plot1=bar_plot.T(label="Cost", data=data, fill_style=fill_style.red)
plot2=bar_plot.T(label="Revenue", data=data, hcol=2, stack_on = plot1, fill_style=fill_style.blue)
plot1 = bar_plot.T(label="Cost", data=data, fill_style=fill_style.red)
plot2 = bar_plot.T(label="Revenue", data=data, hcol=2, stack_on = plot1, fill_style=fill_style.blue)
ar.add_plot(plot1, plot2)
@ -154,14 +170,14 @@ class report_custom(report_int):
can.line(line_style.black, 0, 0, 300, 50)
# vertical lines
ls = line_style.T(width=0.4, color=color.gray70, dash=(2,2))
ls = line_style.T(width=0.4, color=color.gray70, dash=(2, 2))
for x in range(120, 300, 60):
can.line(ls, x, 0, x, 250)
# draw arrows to the right
a = arrow.fat1
for y in range(60,150,10):
a.draw([(285,y), (315,y)], can=can)
for y in range(60, 150, 10):
a.draw([(285, y), (315, y)], can=can)
# close canvas so that the file is written to "disk"
can.close()
@ -174,6 +190,5 @@ class report_custom(report_int):
report_custom('report.crm.case')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: