[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
This commit is contained in:
committed by
Thibault Delavallée
parent
6044782aef
commit
72f907f32a
@@ -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,
|
||||
|
||||
@@ -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>
|
||||
@@ -5,3 +5,4 @@ from . import im_livechat_channel
|
||||
from . import ir_autovacuum
|
||||
from . import mail_channel
|
||||
from . import rating
|
||||
from . import digest
|
||||
|
||||
@@ -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
|
||||
@@ -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"
|
||||
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user