-
Notifications
You must be signed in to change notification settings - Fork 47
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
max3903
merged 2 commits into
ursais:12.0
from
murtuzasaleh:connector_voicent_helpdesk_ticket_v12
Jun 20, 2019
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
17 changes: 17 additions & 0 deletions
17
connector_voicent_helpdesk_ticket/models/backend_voicent_call_line.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
106
connector_voicent_helpdesk_ticket/models/helpdesk_ticket.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
59
connector_voicent_helpdesk_ticket/tests/test_helpdesk_ticket.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}) |
16 changes: 16 additions & 0 deletions
16
connector_voicent_helpdesk_ticket/view/backend_voicent_call_line_view.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?