Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] connector_voicent_helpdesk_ticket #97

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ env:

matrix:
- LINT_CHECK="1"
- TESTS="1" ODOO_REPO="OCA/OCB" LINT_CHECK="0" EXCLUDE="helpdesk_ticket_type_default_priority,helpdesk_phone,helpdesk_scope,helpdesk_ticket_to_task,agreement_rma,helpdesk_stock,agreement_helpdesk,helpdesk_fieldservice,agreement_sale_subscription,helpdesk_resolution,fieldservice_helpdesk_stock,helpdesk_ticket_parent,fieldservice_agreement_helpdesk,helpdesk_stage_server_action,helpdesk_team_assigned_tickets"
- TESTS="1" ODOO_REPO="odoo/odoo" LINT_CHECK="0" EXCLUDE="helpdesk_ticket_type_default_priority,helpdesk_phone,helpdesk_scope,helpdesk_ticket_to_task,agreement_rma,helpdesk_stock,agreement_helpdesk,helpdesk_fieldservice,agreement_sale_subscription,helpdesk_resolution,fieldservice_helpdesk_stock,helpdesk_ticket_parent,fieldservice_agreement_helpdesk,helpdesk_stage_server_action,helpdesk_team_assigned_tickets"
- TESTS="1" ODOO_REPO="OCA/OCB" LINT_CHECK="0" EXCLUDE="helpdesk_ticket_type_default_priority,helpdesk_phone,helpdesk_scope,helpdesk_ticket_to_task,agreement_rma,helpdesk_stock,agreement_helpdesk,helpdesk_fieldservice,agreement_sale_subscription,helpdesk_resolution,fieldservice_helpdesk_stock,helpdesk_ticket_parent,fieldservice_agreement_helpdesk,helpdesk_stage_server_action,helpdesk_team_assigned_tickets,connector_voicent_helpdesk_ticket"
- TESTS="1" ODOO_REPO="odoo/odoo" LINT_CHECK="0" EXCLUDE="helpdesk_ticket_type_default_priority,helpdesk_phone,helpdesk_scope,helpdesk_ticket_to_task,agreement_rma,helpdesk_stock,agreement_helpdesk,helpdesk_fieldservice,agreement_sale_subscription,helpdesk_resolution,fieldservice_helpdesk_stock,helpdesk_ticket_parent,fieldservice_agreement_helpdesk,helpdesk_stage_server_action,helpdesk_team_assigned_tickets,connector_voicent_helpdesk_ticket"

install:
- git clone --depth=1 https://github.com/ursais/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools
Expand Down
50 changes: 50 additions & 0 deletions connector_voicent_helpdesk_ticket/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3

=================================
Voicent Helpdesk Ticket Connector
=================================

Odoo Helpdesk App does not provide an automated way to trigger phone calls when a ticket reaches a specific stage in the process.

For companies with a large number of tickets or when a ticket impacts many people, calling everyone one by one is a time-consuming option.

This module aims to automate calls to customer or impacted third parties when a ticket reaches a specific stage.

Configuration
=============

* Go to Connectors > Backends > Voicent Backends
* Create a Voicent Backend with the host, port, caller ID, number of lines
* Create Time lines to determine at which time of the day the calls are made
* Create Call lines to determine at which stage in the process the calls are made.

+------------+-----+----------------+--------------+
| | | Ticket has a parent |
+------------+-----+----------------+--------------+
| | | Yes | No |
+------------+-----+----------------+--------------+
| Must Have | Yes | Call | No Call |
+ +-----+----------------+--------------+
| a Parent | No | Call |
+------------+-----+----------------+--------------+

* Go to Contacts
* Review customers to set the "Accepts Calls" box or not

Usage
=====

To use this module, you need to:

* Go to Helpdesk
* Create a ticket and assign it to a customer who accepts phone calls
* Move the ticket to the stage specified in the call lines of the backend
* Check the chatter for the call status

Contributors
------------

* Maxime Chambreuil <mchambreuil@opensourceintegrators.com>
* Murtuza Saleh <murtuza.saleh@serpentcs.com>
5 changes: 5 additions & 0 deletions connector_voicent_helpdesk_ticket/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (C) 2019 Open Source Integrators
# <https://www.opensourceintegrators.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import models
24 changes: 24 additions & 0 deletions connector_voicent_helpdesk_ticket/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (C) 2019 Open Source Integrators
# <https://www.opensourceintegrators.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

{
"name": "Voicent Helpdesk Ticket Connector",
"version": "12.0.1.0.0",
"license": "LGPL-3",
"category": "connector",
"author": "Open Source Integrators",
"summary": """Automate calls to customers when tickets reach a stage""",
"website": "https://github.com/ursais/osi-addons",
"depends": [
"connector_voicent",
"helpdesk_ticket_parent",
],
"data": [
"view/backend_voicent_call_line_view.xml",
],
"development_status": "Beta",
"maintainers": [
"max3903",
],
}
6 changes: 6 additions & 0 deletions connector_voicent_helpdesk_ticket/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright (C) 2019 Open Source Integrators
# <https://www.opensourceintegrators.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import backend_voicent_call_line
from . import helpdesk_ticket
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (C) 2019 Open Source Integrators
# <https://www.opensourceintegrators.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import fields, models


class BackendVoicentCallLine(models.Model):
_inherit = 'backend.voicent.call.line'

applies_on = fields.Selection(
selection_add=[('helpdesk_ticket', 'Helpdesk Ticket')])
helpdesk_ticket_stage_id = fields.Many2one(
'helpdesk.stage',
string='Helpdesk Ticket Stage')
has_parent = fields.Boolean('Must Have a Parent', help="""Determine if the call is
made based on whether the parent of the ticket is set or not""")
106 changes: 106 additions & 0 deletions connector_voicent_helpdesk_ticket/models/helpdesk_ticket.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Copyright (C) 2019 Open Source Integrators
# <https://www.opensourceintegrators.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

import io
import base64
from odoo import api, models, _
from ...queue_job.job import job
from odoo.tools import pycompat
from ...connector_voicent.examples import voicent
import tempfile
import shutil


class HelpdeskTicket(models.Model):
_inherit = 'helpdesk.ticket'

@job
@api.multi
def check_status_job(self, voicent_campaign, helpdesk_ticket,
call_line):
for rec in self:
voicent_obj = voicent.Voicent(
call_line.backend_id.host,
str(call_line.backend_id.port),
call_line.backend_id.callerid,
str(call_line.backend_id.line))
status = voicent_obj.checkStatus(voicent_campaign)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guewen How can we get this job to be retried if the status returned by Voicent is not OK?

message = _("""Status of campaign <b>%s</b> on <b>%s</b>:
%s""" % (voicent_campaign,
call_line.backend_id.name,
status))
helpdesk_ticket.message_post(body=message)

@job
@api.multi
def voicent_import_and_runcampaign(self, helpdesk_ticket, call_line):
for rec in self:
if call_line.helpdesk_ticket_stage_id.id \
== helpdesk_ticket.stage_id.id:
# Generate the CSV file
fp = io.BytesIO()
writer = pycompat.csv_writer(fp, quoting=1)
writer.writerow(("Name", "Phone"))
writer.writerow(
[helpdesk_ticket.partner_id.name,
helpdesk_ticket.partner_id.phone])
directory = tempfile.mkdtemp(suffix='-helpdesk.ticket')
file_name = directory + "/" + rec.name + rec.stage_id.name +\
".csv"
write_file = open(file_name, 'wb')
write_file.write(fp.getvalue())
write_file.close()
# Contact Voicent
voicent_obj = voicent.Voicent(
call_line.backend_id.host,
str(call_line.backend_id.port),
call_line.backend_id.callerid,
str(call_line.backend_id.line))
res = voicent_obj.importAndRunCampaign(file_name, "tts",
call_line.voicent_app)
# Attach the file to the ticket
self.env['ir.attachment'].create({
'name': rec.name,
'datas': base64.encodestring(fp.getvalue()),
'datas_fname': "%s.csv" % (rec.name),
'res_model': 'helpdesk.ticket',
'res_id': rec.id})
# Delete the file on the filesystem
shutil.rmtree(dir)
if res.get('camp_id'):
message = _("""Call has been sent to <b>%s</b>.
The campaign ID is <b>%s</b> and the status is: %s""" %
(call_line.backend_id.name,
res.get('camp_id'),
res.get('status')))
rec.with_delay().check_status_job(
res.get('camp_id'),
helpdesk_ticket,
call_line)
else:
message = _("""Call has been sent to <b>%s</b> but failed
with the following message: %s""" %
(call_line.backend_id.name,
res))
else:
message = _("Call has been cancelled because the stage has "
"changed.")
helpdesk_ticket.message_post(body=message)

@api.multi
def write(self, vals):
for rec in self:
if vals.get('stage_id') and rec.partner_id.company_type and \
rec.partner_id.can_call:
call_lines = self.env['backend.voicent.call.line'].search(
[('helpdesk_ticket_stage_id', '=',
vals.get('stage_id')),
('backend_id.active', '=', True)])
for line_rec in call_lines:
if not (line_rec.has_parent is True and
rec.parent_id is False):
rec.with_delay(
eta=line_rec.backend_id.next_call). \
voicent_import_and_runcampaign(rec, line_rec)
return super(HelpdeskTicket, self).write(vals)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions connector_voicent_helpdesk_ticket/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (C) 2019 Open Source Integrators
# <https://www.opensourceintegrators.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import test_helpdesk_ticket
59 changes: 59 additions & 0 deletions connector_voicent_helpdesk_ticket/tests/test_helpdesk_ticket.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Copyright (C) 2019 Open Source Integrators
# <https://www.opensourceintegrators.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo.tests.common import TransactionCase


class TestHelpdeskTicket(TransactionCase):

def setUp(self):
super(TestHelpdeskTicket, self).setUp()
self.backend_voicent_model = self.env['backend.voicent']
self.res_partner_model = self.env['res.partner']
self.helpdesk_ticket_model = self.env['helpdesk.ticket']
self.helpdesk_stage_model = self.env['helpdesk.stage']

def test_helpdesk_ticket_change_stage(self):
self.res_partner_id = self.res_partner_model.create(
{'name': 'Test Azure Interior',
'company_type': 'person',
'can_call': True})

self.helpdesk_stage_model_id = self.helpdesk_stage_model.create(
{'name': 'New'})

self.helpdesk_stage_in_progress_id = self.helpdesk_stage_model.create(
{'name': 'In Progress'})

self.helpdesk_ticket_id = self.helpdesk_ticket_model.create(
{'name': 'Test Kitchen collapsing',
'partner_id': self.res_partner_id.id,
'stage_id': self.helpdesk_stage_model_id.id})

self.backend_voicent_id = self.backend_voicent_model.create(
{'name': 'Test',
'host': 'localhost',
'port': '8155',
'callerid': '0000000000',
'line': '4',
'active': True,
'call_line_ids': [(0, 0, {'name': 'call 1',
'applies_on': False,
'helpdesk_ticket_stage_id':
self.helpdesk_stage_in_progress_id.id,
'voicent_app': 'App'
})],
'time_line_ids': [(0, 0, {'name': 'Call Time 1',
'time': 10.0}),
(0, 0, {'name': 'Call Time 2',
'time': 11.0}),
(0, 0, {'name': 'Call Time 3',
'time': 12.0}),
(0, 0, {'name': 'Call Time 4',
'time': 16.46})]
})
self.backend_voicent_id._run_update_next_call()

self.helpdesk_ticket_id.write(
{'stage_id': self.helpdesk_stage_in_progress_id.id})
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<odoo>

<record id="backend_voicent_form_view_inherit" model="ir.ui.view">
<field name="name">backend.voicent.form.view.inherit</field>
<field name="model">backend.voicent</field>
<field name="inherit_id"
ref="connector_voicent.backend_voicent_form_view"/>
<field name="arch" type="xml">
<field name="applies_on" position="after">
<field name="helpdesk_ticket_stage_id"/>
<field name="has_parent"/>
</field>
</field>
</record>

</odoo>
1 change: 1 addition & 0 deletions oca_dependencies.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
odoo-addons https://github.com/gityopie/odoo-addons.git 12.0
connector-telephony
field-service
stock-logistics-warehouse