[ADD/MOD] crm_helpdesk : new report added for helpdesk
authorVir (Open ERP) <vir@tinyerp.com>
Mon, 15 Mar 2010 11:56:28 +0000 (17:26 +0530)
committerVir (Open ERP) <vir@tinyerp.com>
Mon, 15 Mar 2010 11:56:28 +0000 (17:26 +0530)
bzr revid: vir@tinyerp.com-20100315115628-sop2obsidgbnyok9

addons/crm/__terp__.py
addons/crm/report/__init__.py
addons/crm/report/crm_helpdesk_report.py [new file with mode: 0644]
addons/crm/report/crm_helpdesk_report_view.xml [new file with mode: 0644]

index 994f11f..72222a0 100644 (file)
@@ -41,73 +41,74 @@ appropriate staff, and making sure all future correspondence gets to the right
 place.
 
 The CRM module has a email gateway for the synchronisation interface
-between mails and Open ERP.""", 
-    'author': 'Tiny', 
-    'website': 'http://www.openerp.com', 
-    'depends': ['base', 'base_action_rule',                         
-                        'process', 
-                        'mail_gateway', 
+between mails and Open ERP.""",
+    'author': 'Tiny',
+    'website': 'http://www.openerp.com',
+    'depends': ['base', 'base_action_rule',
+                        'process',
+                        'mail_gateway',
                         'base_calendar',
-                    ], 
-    'init_xml': ['crm_data.xml', 
-                'crm_meeting_data.xml', 
-                 'crm_claims_data.xml', 
-                 'crm_fund_data.xml', 
-                 'crm_helpdesk_data.xml', 
-                 'crm_lead_data.xml', 
-                 'crm_meeting_data.xml', 
-                 'crm_opportunity_data.xml', 
-                 'crm_phonecall_data.xml', 
-    ], 
+                    ],
+    'init_xml': ['crm_data.xml',
+                'crm_meeting_data.xml',
+                 'crm_claims_data.xml',
+                 'crm_fund_data.xml',
+                 'crm_helpdesk_data.xml',
+                 'crm_lead_data.xml',
+                 'crm_meeting_data.xml',
+                 'crm_opportunity_data.xml',
+                 'crm_phonecall_data.xml',
+    ],
 
     'update_xml': [
-        'crm_wizard.xml', 
-        'crm_view.xml', 
-        'crm_action_rule_view.xml', 
-        'crm_lead_wizard.xml', 
-        'crm_lead_view.xml', 
-        'crm_lead_menu.xml', 
-        'crm_meeting_wizard.xml', 
-        'crm_meeting_view.xml', 
-        'crm_meeting_menu.xml', 
-        'crm_phonecall_wizard.xml', 
-        'crm_phonecall_view.xml', 
-        'crm_phonecall_menu.xml',         
-        'crm_opportunity_wizard.xml', 
-        'crm_opportunity_view.xml', 
-        'crm_opportunity_menu.xml', 
-        'crm_fund_view.xml', 
-        'crm_fund_menu.xml', 
-        'crm_claims_view.xml', 
-        'crm_claims_menu.xml', 
+        'crm_wizard.xml',
+        'crm_view.xml',
+        'crm_action_rule_view.xml',
+        'crm_lead_wizard.xml',
+        'crm_lead_view.xml',
+        'crm_lead_menu.xml',
+        'crm_meeting_wizard.xml',
+        'crm_meeting_view.xml',
+        'crm_meeting_menu.xml',
+        'crm_phonecall_wizard.xml',
+        'crm_phonecall_view.xml',
+        'crm_phonecall_menu.xml',
+        'crm_opportunity_wizard.xml',
+        'crm_opportunity_view.xml',
+        'crm_opportunity_menu.xml',
+        'crm_fund_view.xml',
+        'crm_fund_menu.xml',
+        'crm_claims_view.xml',
+        'crm_claims_menu.xml',
 
         'crm_helpdesk_view.xml',
-        'crm_helpdesk_menu.xml', 
-         
-        'security/crm_security.xml', 
-        'security/ir.model.access.csv', 
+        'crm_helpdesk_menu.xml',
+
+        'security/crm_security.xml',
+        'security/ir.model.access.csv',
 
         'report/crm_report_view.xml',
         'report/crm_claim_report_view.xml',
         'report/crm_lead_report_view.xml',
         'report/crm_fundraising_report_view.xml',
-        'report/crm_opportunity_report_view.xml' ,       
+        'report/crm_opportunity_report_view.xml' ,
         'report/crm_phonecall_report_view.xml',
-        
+        'report/crm_helpdesk_report_view.xml',
+
         'process/crm_configuration_process.xml',
-        
+
     ],
     'demo_xml': [
-        'crm_demo.xml', 
-        'crm_claims_demo.xml', 
-        'crm_fund_demo.xml', 
-        'crm_helpdesk_demo.xml', 
-        'crm_lead_demo.xml', 
-        'crm_meeting_demo.xml', 
-        'crm_opportunity_demo.xml', 
-        'crm_phonecall_demo.xml'], 
-    'installable': True, 
-    'active': False, 
-    'certificate': '0079056041421', 
+        'crm_demo.xml',
+        'crm_claims_demo.xml',
+        'crm_fund_demo.xml',
+        'crm_helpdesk_demo.xml',
+        'crm_lead_demo.xml',
+        'crm_meeting_demo.xml',
+        'crm_opportunity_demo.xml',
+        'crm_phonecall_demo.xml'],
+    'installable': True,
+    'active': False,
+    'certificate': '0079056041421',
 }
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
index c93c51d..7030c43 100644 (file)
@@ -26,6 +26,7 @@ import crm_lead_report
 import crm_phonecall_report
 import crm_fundraising_report
 import crm_opportunity_report
+import crm_helpdesk_report
 
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
 
diff --git a/addons/crm/report/crm_helpdesk_report.py b/addons/crm/report/crm_helpdesk_report.py
new file mode 100644 (file)
index 0000000..7a85537
--- /dev/null
@@ -0,0 +1,63 @@
+# -*- 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_helpdesk_report(osv.osv):
+    _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),
+        'date_deadline': fields.date('Deadline'),
+        'priority': fields.selection([('5','Lowest'),('4','Low'),('3','Normal'),('2','High'),('1','Highest')], 'Priority'),
+    }
+
+    def init(self, cr):
+        tools.drop_view_if_exists(cr, 'crm_helpdesk_report')
+        cr.execute("""
+            create or replace view crm_helpdesk_report 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.partner_id,
+                    c.company_id,
+                    c.priority,
+                    c.date_deadline,
+                    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_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
+            )""")
+crm_helpdesk_report()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/crm/report/crm_helpdesk_report_view.xml b/addons/crm/report/crm_helpdesk_report_view.xml
new file mode 100644 (file)
index 0000000..7658409
--- /dev/null
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+       <!--
+       Helpdesk report after Sales Services
+       -->
+
+        <record id="view_report_crm_helpdesk_tree" model="ir.ui.view">
+            <field name="name">crm.helpdesk.report.tree</field>
+            <field name="model">crm.helpdesk.report</field>
+            <field name="type">tree</field>
+            <field name="arch" type="xml">
+               <tree string="Helpdesk">
+                                       <field name="name" />
+                                       <field name="month"/>
+                                       <field name="section_id" />
+                    <field name="user_id" />
+                    <field name="company_id"/>
+                    <field name="partner_id" />
+                    <field name="date_deadline" invisible="1"/>
+                    <field name="priority" invisible="1"/>
+                                       <field name="nbr" string="#Helpdesk" />
+                       <field name="delay_close"/>
+                    <field name="state" invisible="1"/>
+                               </tree>
+            </field>
+        </record>
+        <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>
+            <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_report_crm_helpdesk_graph" model="ir.ui.view">
+            <field name="name">crm.helpdesk.report.graph</field>
+            <field name="model">crm.helpdesk.report</field>
+            <field name="type">graph</field>
+            <field name="arch" type="xml">
+                <graph orientation="horizontal" string="Helpdesk" type="bar">
+                    <field name="state"/>
+                    <field name="nbr" operator="+"/>
+                    <field group="True" name="user_id"/>
+                </graph>
+            </field>
+        </record>
+
+               <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>
+            <field name="type">search</field>
+            <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 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>
+                   <newline/>
+                   <group expand="1" string="Extended options..." colspan="4" col="5">
+                        <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="9">
+                        <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'}"/>
+                        <filter string="Priority" icon="terp-sale" domain="[]" context="{'group_by':'priority'}"/>
+                       <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>
+        <record id="action_report_crm_helpdesk" model="ir.actions.act_window">
+            <field name="name">Helpdesk</field>
+            <field name="res_model">crm.helpdesk.report</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,graph</field>
+            <field name="view_id" ref="view_report_crm_helpdesk_tree"/>
+            <field name="search_view_id" ref="view_report_crm_helpdesk_filter"/>
+        </record>
+
+               <record model="ir.actions.act_window.view" id="action_report_crm_helpdesk_tree">
+               <field name="sequence" eval="1"/>
+               <field name="view_mode">tree</field>
+               <field name="view_id" ref="view_report_crm_helpdesk_tree"/>
+               <field name="act_window_id" ref="action_report_crm_helpdesk"/>
+           </record>
+
+        <record model="ir.actions.act_window.view" id="action_report_crm_helpdesk_graph">
+               <field name="sequence" eval="2"/>
+               <field name="view_mode">graph</field>
+               <field name="view_id" ref="view_report_crm_helpdesk_graph"/>
+               <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"/>
+
+  </data>
+</openerp>
+