summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorVarun Raval <var@odoo.com>2019-02-21 10:29:47 +0000
committerThibault Delavallée <tde@odoo.com>2019-11-26 14:21:45 +0000
commit72f907f32a9fd980862d9bc39a36f1c6860350fc (patch)
tree6713160f38f054a8e5f3b3b19dc62b1266f0cab6 /addons
parent6044782aeffc61955b956068b0a4d58fa33303f0 (diff)
[IMP] im_livechat: add livechat summary in digest
Purpose of the task is to add a Live Chat section in the weekly digest email template. Following value related to livechat are therefore added in digest emails: * hit % of ratings; * amount of conversations he handled; * hit time to answer; Task ID 1883428 closes #29764
Diffstat (limited to 'addons')
-rw-r--r--addons/im_livechat/__manifest__.py4
-rw-r--r--addons/im_livechat/data/digest_data.xml8
-rw-r--r--addons/im_livechat/models/__init__.py1
-rw-r--r--addons/im_livechat/models/digest.py50
-rw-r--r--addons/im_livechat/report/im_livechat_report_channel_views.xml7
-rw-r--r--addons/im_livechat/views/digest_views.xml17
6 files changed, 86 insertions, 1 deletions
diff --git a/addons/im_livechat/__manifest__.py b/addons/im_livechat/__manifest__.py
index 4d988093a94..29b4ec7b371 100644
--- a/addons/im_livechat/__manifest__.py
+++ b/addons/im_livechat/__manifest__.py
@@ -22,6 +22,7 @@ Help your customers with this chat, and analyse their feedback.
"data/mail_shortcode_data.xml",
"data/mail_data.xml",
"data/im_livechat_channel_data.xml",
+ 'data/digest_data.xml',
"security/im_livechat_channel_security.xml",
"security/ir.model.access.csv",
"views/rating_views.xml",
@@ -29,6 +30,7 @@ Help your customers with this chat, and analyse their feedback.
"views/im_livechat_channel_views.xml",
"views/im_livechat_channel_templates.xml",
"views/res_users_views.xml",
+ "views/digest_views.xml",
"report/im_livechat_report_channel_views.xml",
"report/im_livechat_report_operator_views.xml"
],
@@ -36,7 +38,7 @@ Help your customers with this chat, and analyse their feedback.
"data/im_livechat_channel_demo.xml",
'data/mail_shortcode_demo.xml',
],
- 'depends': ["mail", "rating"],
+ 'depends': ["mail", "rating", "digest"],
'qweb': ['static/src/xml/*.xml'],
'installable': True,
'auto_install': False,
diff --git a/addons/im_livechat/data/digest_data.xml b/addons/im_livechat/data/digest_data.xml
new file mode 100644
index 00000000000..32f5b771ae4
--- /dev/null
+++ b/addons/im_livechat/data/digest_data.xml
@@ -0,0 +1,8 @@
+<?xml version='1.0' encoding='utf-8'?>
+<odoo noupdate="1">
+ <record id="digest.digest_digest_default" model="digest.digest">
+ <field name="kpi_livechat_rating">True</field>
+ <field name="kpi_livechat_conversations">True</field>
+ <field name="kpi_livechat_response">True</field>
+ </record>
+</odoo>
diff --git a/addons/im_livechat/models/__init__.py b/addons/im_livechat/models/__init__.py
index ed7159b0294..f70bcc5f3c3 100644
--- a/addons/im_livechat/models/__init__.py
+++ b/addons/im_livechat/models/__init__.py
@@ -5,3 +5,4 @@ from . import im_livechat_channel
from . import ir_autovacuum
from . import mail_channel
from . import rating
+from . import digest
diff --git a/addons/im_livechat/models/digest.py b/addons/im_livechat/models/digest.py
new file mode 100644
index 00000000000..6c0fefd7ae4
--- /dev/null
+++ b/addons/im_livechat/models/digest.py
@@ -0,0 +1,50 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import fields, models
+
+
+class Digest(models.Model):
+ _inherit = 'digest.digest'
+
+ kpi_livechat_rating = fields.Boolean('% of Happiness')
+ kpi_livechat_rating_value = fields.Float(digits=(16, 2), compute='_compute_kpi_livechat_rating_value')
+ kpi_livechat_conversations = fields.Boolean('Conversations handled')
+ kpi_livechat_conversations_value = fields.Integer(compute='_compute_kpi_livechat_conversations_value')
+ kpi_livechat_response = fields.Boolean('Time to answer(sec)', help="Time to answer the user in second.")
+ kpi_livechat_response_value = fields.Float(compute='_compute_kpi_livechat_response_value')
+
+ def _compute_kpi_livechat_rating_value(self):
+ channels = self.env['mail.channel'].search([('livechat_operator_id', '=', self.env.user.partner_id.id)])
+ for record in self:
+ start, end, company = record._get_kpi_compute_parameters()
+ domain = [
+ ('create_date', '>=', start), ('create_date', '<', end),
+ ('rated_partner_id', '=', self.env.user.partner_id.id)
+ ]
+ ratings = channels.rating_get_grades(domain)
+ record.kpi_livechat_rating_value = ratings['great'] * 100 / sum(ratings.values()) if sum(ratings.values()) else 0
+
+ def _compute_kpi_livechat_conversations_value(self):
+ for record in self:
+ start, end, company = record._get_kpi_compute_parameters()
+ record.kpi_livechat_conversations_value = self.env['mail.channel'].search_count([
+ ('channel_type', '=', 'livechat'),
+ ('livechat_operator_id', '=', self.env.user.partner_id.id),
+ ('create_date', '>=', start), ('create_date', '<', end)
+ ])
+
+ def _compute_kpi_livechat_response_value(self):
+ for record in self:
+ start, end, company = record._get_kpi_compute_parameters()
+ response_time = self.env['im_livechat.report.operator'].sudo().read_group([
+ ('start_date', '>=', start), ('start_date', '<', end),
+ ('partner_id', '=', self.env.user.partner_id.id)], ['partner_id', 'time_to_answer'], ['partner_id'])
+ record.kpi_livechat_response_value = "%.2f" % sum([response['time_to_answer'] for response in response_time]) or 0
+
+ def compute_kpis_actions(self, company, user):
+ res = super(Digest, self).compute_kpis_actions(company, user)
+ res['kpi_livechat_rating'] = 'im_livechat.rating_rating_action_livechat_report'
+ res['kpi_livechat_conversations'] = 'im_livechat.im_livechat_report_operator_action'
+ res['kpi_livechat_response'] = 'im_livechat.im_livechat_report_channel_time_to_answer_action'
+ return res
diff --git a/addons/im_livechat/report/im_livechat_report_channel_views.xml b/addons/im_livechat/report/im_livechat_report_channel_views.xml
index f33543f9fff..c9c4f6ae18d 100644
--- a/addons/im_livechat/report/im_livechat_report_channel_views.xml
+++ b/addons/im_livechat/report/im_livechat_report_channel_views.xml
@@ -56,6 +56,13 @@
<field name="help">Livechat Support Channel Statistics allows you to easily check and analyse your company livechat session performance. Extract information about the missed sessions, the audiance, the duration of a session, etc.</field>
</record>
+ <record id="im_livechat_report_channel_time_to_answer_action" model="ir.actions.act_window">
+ <field name="name">Session Statistics</field>
+ <field name="res_model">im_livechat.report.channel</field>
+ <field name="view_mode">graph,pivot</field>
+ <field name="context">{"graph_measure": "time_to_answer", "search_default_last_week":1}</field>
+ </record>
+
<menuitem
id="menu_reporting_livechat_channel"
name="Session Statistics"
diff --git a/addons/im_livechat/views/digest_views.xml b/addons/im_livechat/views/digest_views.xml
new file mode 100644
index 00000000000..4082b2953b8
--- /dev/null
+++ b/addons/im_livechat/views/digest_views.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<odoo>
+ <record id="im_livechat.digest_digest_view_form_inherit" model="ir.ui.view">
+ <field name="name">im.livechat.digest.digest.view.form.inherit</field>
+ <field name="model">digest.digest</field>
+ <field name="inherit_id" ref="digest.digest_digest_view_form" />
+ <field name="arch" type="xml">
+ <xpath expr="//group[@name='kpi_general']" position="after">
+ <group name="kpi_im_livechat" string="Live Chat">
+ <field name="kpi_livechat_rating"/>
+ <field name="kpi_livechat_conversations"/>
+ <field name="kpi_livechat_response"/>
+ </group>
+ </xpath>
+ </field>
+ </record>
+</odoo>