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 @@ + + + + True + True + True + + 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 @@ 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. + + Session Statistics + im_livechat.report.channel + graph,pivot + {"graph_measure": "time_to_answer", "search_default_last_week":1} + + + + + im.livechat.digest.digest.view.form.inherit + digest.digest + + + + + + + + + + + +