[REM]: crm: Removed crm.case report files
bzr revid: rpa@tinyerp.com-20100506063638-e8tgtbvrk0rp5qqs
This commit is contained in:
parent
a139623586
commit
6c9331f6ea
|
@ -1,176 +0,0 @@
|
|||
# -*- 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
|
||||
|
||||
AVAILABLE_STATES = [
|
||||
('draft','Draft'),
|
||||
('open','Open'),
|
||||
('cancel', 'Cancelled'),
|
||||
('done', 'Closed'),
|
||||
('pending','Pending')
|
||||
]
|
||||
AVAILABLE_PRIORITIES = [
|
||||
('5', 'Lowest'),
|
||||
('4', 'Low'),
|
||||
('3', 'Normal'),
|
||||
('2', 'High'),
|
||||
('1', 'Highest')
|
||||
]
|
||||
|
||||
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 user’s ID for security checks,
|
||||
@param ids: List of case and section Data’s 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))
|
||||
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
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Year', size=64, required=False, readonly=True),
|
||||
'user_id':fields.many2one('res.users', 'User', readonly=True),
|
||||
'section_id':fields.many2one('crm.case.section', 'Section', readonly=True),
|
||||
'nbr': fields.integer('# of Cases', readonly=True),
|
||||
'state': fields.selection(AVAILABLE_STATES, '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),
|
||||
'create_date': fields.datetime('Create Date', readonly=True),
|
||||
'day': fields.char('Day', size=128, 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 (
|
||||
select
|
||||
min(c.id) as id,
|
||||
to_char(c.create_date, 'YYYY') as name,
|
||||
to_char(c.create_date, 'MM') as month,
|
||||
to_char(c.create_date, 'YYYY-MM-DD') as day,
|
||||
c.state,
|
||||
c.user_id,
|
||||
c.section_id,
|
||||
c.company_id,
|
||||
count(*) as nbr,
|
||||
c.create_date as create_date
|
||||
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
|
||||
,c.create_date,to_char(c.create_date, 'YYYY-MM-DD')
|
||||
)""")
|
||||
|
||||
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 = {
|
||||
'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,
|
||||
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()
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
@ -1,235 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-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>
|
||||
<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>
|
||||
|
||||
<!-- 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>
|
||||
<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>
|
||||
|
||||
<!-- 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>
|
||||
<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>
|
||||
|
||||
<!-- CRM Case Report Search View -->
|
||||
|
||||
<record id="view_crm_report_filter" model="ir.ui.view">
|
||||
<field name="name">crm.case.report.select</field>
|
||||
<field name="model">crm.case.report</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search">
|
||||
<group col="16" colspan="8">
|
||||
<!-- <filter string="This Year" name="This Year" icon="terp-hr"
|
||||
domain="[('name','=',time.localtime()[0])]"/>-->
|
||||
<filter string="This Year" icon="terp-hr"
|
||||
domain="[('create_date','<=', time.strftime('%%Y-%%m-%%d')), ('create_date','>',(datetime.date.today()-datetime.timedelta(days=365)).strftime('%%Y-%%m-%%d'))]"/>
|
||||
|
||||
<!-- <filter string="This Month" name="This Year" icon="terp-hr"
|
||||
domain="[('month','=',time.strftime('%%m'))]" />-->
|
||||
<filter string="This Month" icon="terp-hr" name="This Month"
|
||||
domain="[('create_date','<=', time.strftime('%%Y-%%m-%%d')), ('create_date','>',(datetime.date.today()-datetime.timedelta(days=30)).strftime('%%Y-%%m-%%d'))]"/>
|
||||
|
||||
<filter icon="gtk-media-rewind" string="7 Days" separator="1"
|
||||
domain="[('create_date','<=', time.strftime('%%Y-%%m-%%d')), ('create_date','>',(datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]"/>
|
||||
|
||||
<separator orientation="vertical" />
|
||||
<filter icon="terp-hr"
|
||||
string="Draft"
|
||||
domain="[('state','=','draft')]"/>
|
||||
<filter icon="terp-hr"
|
||||
string="Open"
|
||||
domain="[('state','=','open')]"/>
|
||||
<filter icon="terp-hr"
|
||||
string="Pending"
|
||||
domain="[('state','=','pending')]"/>
|
||||
|
||||
<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 Case" help="My Case" domain="[('user_id','=',uid)]" />
|
||||
</field>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="0" string="Extended options..." colspan="10" col="12">
|
||||
<filter icon="terp-sale"
|
||||
string="Done"
|
||||
domain="[('state','=','done')]"/>
|
||||
|
||||
<filter icon="terp-sale"
|
||||
string="Cancel"
|
||||
domain="[('state','=','cancel')]"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="1" string="Group By..." colspan="4" col="8">
|
||||
<filter string="User" name="User" icon="terp-sale"
|
||||
domain="[]" context="{'group_by':'user_id'}" />
|
||||
|
||||
<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="Day" icon="terp-sale"
|
||||
domain="[]" context="{'group_by':'day'}"/>
|
||||
|
||||
<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>
|
||||
<field name="res_model">crm.case.report</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>
|
||||
|
||||
<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_categ"
|
||||
name="Monthly cases by Sales Team" res_model="crm.case.report"
|
||||
src_model="crm.case.section" />
|
||||
|
||||
<!-- 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>
|
||||
<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_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="name"/>
|
||||
<field name="user_id" select="2"/>
|
||||
<field name="state" />
|
||||
</tree>
|
||||
</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>
|
||||
<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>
|
Loading…
Reference in New Issue