Browse Source

Jan 01 [ADD] : Initial Commit 'odoo_zendesk_connector'

pull/309/head
AjmalCybro 4 months ago
parent
commit
d846584be8
  1. 52
      odoo_zendesk_connector/README.rst
  2. 22
      odoo_zendesk_connector/__init__.py
  3. 46
      odoo_zendesk_connector/__manifest__.py
  4. 5
      odoo_zendesk_connector/doc/RELEASE_NOTES.md
  5. 24
      odoo_zendesk_connector/models/__init__.py
  6. 225
      odoo_zendesk_connector/models/import_export_ticket.py
  7. 82
      odoo_zendesk_connector/models/res_config_settings.py
  8. 214
      odoo_zendesk_connector/models/ticket_helpdesk.py
  9. 3
      odoo_zendesk_connector/security/ir.model.access.csv
  10. BIN
      odoo_zendesk_connector/static/description/assets/icons/check.png
  11. BIN
      odoo_zendesk_connector/static/description/assets/icons/chevron.png
  12. BIN
      odoo_zendesk_connector/static/description/assets/icons/cogs.png
  13. BIN
      odoo_zendesk_connector/static/description/assets/icons/consultation.png
  14. BIN
      odoo_zendesk_connector/static/description/assets/icons/ecom-black.png
  15. BIN
      odoo_zendesk_connector/static/description/assets/icons/education-black.png
  16. BIN
      odoo_zendesk_connector/static/description/assets/icons/hotel-black.png
  17. BIN
      odoo_zendesk_connector/static/description/assets/icons/license.png
  18. BIN
      odoo_zendesk_connector/static/description/assets/icons/lifebuoy.png
  19. BIN
      odoo_zendesk_connector/static/description/assets/icons/manufacturing-black.png
  20. BIN
      odoo_zendesk_connector/static/description/assets/icons/pos-black.png
  21. BIN
      odoo_zendesk_connector/static/description/assets/icons/puzzle.png
  22. BIN
      odoo_zendesk_connector/static/description/assets/icons/restaurant-black.png
  23. BIN
      odoo_zendesk_connector/static/description/assets/icons/service-black.png
  24. BIN
      odoo_zendesk_connector/static/description/assets/icons/trading-black.png
  25. BIN
      odoo_zendesk_connector/static/description/assets/icons/training.png
  26. BIN
      odoo_zendesk_connector/static/description/assets/icons/update.png
  27. BIN
      odoo_zendesk_connector/static/description/assets/icons/user.png
  28. BIN
      odoo_zendesk_connector/static/description/assets/icons/wrench.png
  29. BIN
      odoo_zendesk_connector/static/description/assets/misc/Cybrosys R.png
  30. BIN
      odoo_zendesk_connector/static/description/assets/misc/categories.png
  31. BIN
      odoo_zendesk_connector/static/description/assets/misc/check-box.png
  32. BIN
      odoo_zendesk_connector/static/description/assets/misc/compass.png
  33. BIN
      odoo_zendesk_connector/static/description/assets/misc/corporate.png
  34. BIN
      odoo_zendesk_connector/static/description/assets/misc/customer-support.png
  35. BIN
      odoo_zendesk_connector/static/description/assets/misc/cybrosys-logo.png
  36. BIN
      odoo_zendesk_connector/static/description/assets/misc/features.png
  37. BIN
      odoo_zendesk_connector/static/description/assets/misc/logo.png
  38. BIN
      odoo_zendesk_connector/static/description/assets/misc/pictures.png
  39. BIN
      odoo_zendesk_connector/static/description/assets/misc/pie-chart.png
  40. BIN
      odoo_zendesk_connector/static/description/assets/misc/right-arrow.png
  41. BIN
      odoo_zendesk_connector/static/description/assets/misc/star.png
  42. BIN
      odoo_zendesk_connector/static/description/assets/misc/support.png
  43. BIN
      odoo_zendesk_connector/static/description/assets/misc/whatsapp.png
  44. BIN
      odoo_zendesk_connector/static/description/assets/modules/1.jpg
  45. BIN
      odoo_zendesk_connector/static/description/assets/modules/3.png
  46. BIN
      odoo_zendesk_connector/static/description/assets/modules/4.jpg
  47. BIN
      odoo_zendesk_connector/static/description/assets/modules/5.png
  48. BIN
      odoo_zendesk_connector/static/description/assets/modules/6.png
  49. BIN
      odoo_zendesk_connector/static/description/assets/modules/banner.gif
  50. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/hero.gif
  51. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/oz0018.png
  52. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/oz0019.png
  53. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/oz1.png
  54. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/oz13.png
  55. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/oz16.png
  56. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/oz17.png
  57. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/oz2.png
  58. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/oz3.png
  59. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/oz4.png
  60. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/oz5.png
  61. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/oz8.png
  62. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/zendesk-1.png
  63. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/zendesk-10.png
  64. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/zendesk-11.png
  65. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/zendesk-12.png
  66. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/zendesk-13.png
  67. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/zendesk-14.png
  68. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/zendesk-15.png
  69. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/zendesk-16.png
  70. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/zendesk-17.png
  71. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/zendesk-2.png
  72. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/zendesk-3.png
  73. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/zendesk-4.png
  74. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/zendesk-5.png
  75. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/zendesk-6.png
  76. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/zendesk-7.png
  77. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/zendesk-8.png
  78. BIN
      odoo_zendesk_connector/static/description/assets/screenshots/zendesk-9.png
  79. BIN
      odoo_zendesk_connector/static/description/banner.jpg
  80. BIN
      odoo_zendesk_connector/static/description/icon.png
  81. 1138
      odoo_zendesk_connector/static/description/index.html
  82. 44
      odoo_zendesk_connector/views/import_export_ticket_views.xml
  83. 77
      odoo_zendesk_connector/views/res_config_settings_views.xml
  84. 26
      odoo_zendesk_connector/views/ticket_helpdesk_views.xml

52
odoo_zendesk_connector/README.rst

@ -0,0 +1,52 @@
.. image:: https://img.shields.io/badge/licence-LGPL--3-green.svg
:target: https://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
Odoo Zendesk Connector
=======================
* This module will allow you to integrate the Odoo helpdesk with Zendesk,
enabling you to create, update, and delete tickets. Additionally, it facilitates
the import and export of tickets between Odoo and Zendesk.
Configuration
=============
* Enable Connect Zendesk in the configuration setting and provide your Company Domain,
Company Email, API key and the Password
Company
-------
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__
License
-------
Lesser General Public License, Version 3 (LGPL v3).
(https://www.gnu.org/licenses/lgpl-3.0-standalone.html)
Credits
-------
* Developer:(v16) Anjana P V, Contact: odoo@cybrosys.com
(v17) Dhanya B , Contact: odoo@cybrosys.com
Contacts
--------
* Mail Contact : odoo@cybrosys.com
* Website : https://cybrosys.com
Installation
============
- www.odoo.com/documentation/16.0/setup/install.html
- Install our custom addon
Bug Tracker
-----------
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported.
Maintainer
==========
.. image:: https://cybrosys.com/images/logo.png
:target: https://cybrosys.com
This module is maintained by Cybrosys Technologies.
For support and more information, please visit https://www.cybrosys.com
Further information
===================
HTML Description: `<static/description/index.html>`__

22
odoo_zendesk_connector/__init__.py

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
from . import models

46
odoo_zendesk_connector/__manifest__.py

@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
{
'name': 'Odoo Zendesk Connector',
'version': '17.0.1.0.0',
'category': 'Productivity',
'summary': """Connects Helpdesk in Odoo and Zendesk""",
'description': """This module will allow you to integrate the Odoo
helpdesk with Zendesk,enabling you to create, update, and delete tickets.
Additionally, it facilitates the import and export of tickets between
Odoo and Zendesk.""",
'author': 'Cybrosys Techno Solutions',
'company': 'Cybrosys Techno Solutions',
'maintainer': 'Cybrosys Techno Solutions',
'website': "https://www.cybrosys.com",
'depends': ['mail', 'odoo_website_helpdesk'],
'data': [
'security/ir.model.access.csv',
'views/import_export_ticket_views.xml',
'views/res_config_settings_views.xml',
'views/ticket_helpdesk_views.xml'],
'images': ['static/description/banner.jpg'],
'license': 'LGPL-3',
'installable': True,
'auto_install': False,
'application': False
}

5
odoo_zendesk_connector/doc/RELEASE_NOTES.md

@ -0,0 +1,5 @@
## Module <odoo_zendesk_connector>
#### 22.07.2024
#### Version 17.0.1.0.0
##### ADD
- Initial Commit for Odoo Zendesk Connector

24
odoo_zendesk_connector/models/__init__.py

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
from .import import_export_ticket
from .import res_config_settings
from .import ticket_helpdesk

225
odoo_zendesk_connector/models/import_export_ticket.py

@ -0,0 +1,225 @@
# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
import json
import requests
from datetime import datetime, time
from odoo import api, fields, models, _
from odoo.exceptions import ValidationError, UserError
class ImportExportTicket(models.TransientModel):
"""This class is used to import and export the tickets between odoo and
zendesk"""
_name = 'import.export.ticket'
_description = 'Import and Export Tickets'
_inherit = 'mail.thread'
start_date = fields.Date(string='Start Date',
help='Mention the start date', Required=True)
end_date = fields.Date(string='End Date', help='Mention the end date',
Required=True)
@api.constrains('start_date', 'end_date')
def check_start_date(self):
"""This function is used to validate the entered date"""
if not self.start_date or not self.end_date:
raise ValidationError(_("Please provide the dates"))
if self.start_date > self.end_date:
raise ValidationError(_("Please check the date that you "
"provide"))
def action_import_tickets(self):
"""This function is used to import the tickets from Zendesk"""
company_domain = self.env['ir.config_parameter'].sudo().get_param(
'odoo_zendesk_connector.company_domain')
company_email = self.env['ir.config_parameter'].sudo().get_param(
'odoo_zendesk_connector.company_email')
api_key = self.env['ir.config_parameter'].sudo().get_param(
'odoo_zendesk_connector.api_key')
url = f"https://{company_domain}.zendesk.com/api/v2/tickets.json"
headers = {
"Content-Type": "application/json",
}
auth = (f"{company_email}/token", api_key)
response = requests.get(url, headers=headers, auth=auth)
if response.ok:
tickets = response.json()["tickets"]
for ticket in tickets:
zendesk_ticket_date = datetime.strptime(
ticket["created_at"],
'%Y-%m-%dT%H:%M:%SZ').date()
if self.start_date <= zendesk_ticket_date <= self.end_date:
exist_ticket = self.env['ticket.helpdesk'].search(
[('zendesk_ticket_no', '=', ticket["id"])])
if not exist_ticket:
requester_id = ticket["requester_id"]
requester_url = f'https://{company_domain}.zendesk.com/api/v2/users/{requester_id}.json'
requester_response = requests.get(requester_url,
headers=headers,
auth=auth,
timeout=60)
if response.status_code == 200:
requester_data = requester_response.json()['user']
requester_name = requester_data['name']
requester_email = requester_data['email']
customer = self.env['res.partner'].search(
[('name', '=', requester_name),
('email', '=', requester_email)]).id
if not customer:
new_customer = self.env['res.partner'].create({
'name': requester_name,
'email': requester_email
})
customer = new_customer.id
else:
pass
priority_field = {
None: '0',
'low': '1',
'normal': '2',
'high': '3',
'urgent': '4'
}
priority = priority_field.get(ticket["priority"],
'0')
self.env['ticket.helpdesk'].create({
"subject": ticket["subject"],
"description": ticket["description"],
'priority': priority,
'is_ticket_from_zendesk': True,
'zendesk_ticket_no': ticket["id"],
'customer_id': customer,
'email': requester_email,
})
notification = {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': _("Success!"),
'message': _("Tickets are imported"
" successfully"),
'sticky': False,
}
}
else:
notification = {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': _("Error!"),
'message': _(
"It seems to have some issue with importing "
"the tickets"),
'sticky': False,
}
}
return notification
def action_export_tickets(self):
"""This function is used to export tickets from odoo to zendesk"""
company_domain = self.env['ir.config_parameter'].sudo().get_param(
'odoo_zendesk_connector.company_domain')
company_email = self.env['ir.config_parameter'].sudo().get_param(
'odoo_zendesk_connector.company_email')
api_key = self.env['ir.config_parameter'].sudo().get_param(
'odoo_zendesk_connector.api_key')
export_start_date = datetime.combine(self.start_date, time.min)
export_end_date = datetime.combine(self.end_date, time.min)
headers = {'content-type': 'application/json'}
tickets_rec = self.env['ticket.helpdesk'].search(
[('create_date', '>=', export_start_date),
('create_date', '<=', export_end_date),
('is_ticket_from_zendesk', '=', False),
])
for rec in tickets_rec:
zen_id_search_url = f'https://{company_domain}.zendesk.com/api/v2/tickets/{rec.zendesk_ticket_no}.json'
zen_id_search_response = requests.get(zen_id_search_url, auth=(
f"{company_email}/token", api_key))
customer_id = None
if zen_id_search_response.status_code != 200:
priority = {
'1': 'low',
'2': 'normal',
'3': 'high',
'4': 'urgent'
}
zen_prio = 'None'
if rec.priority in priority:
zen_prio = priority[rec.priority]
customer_search_url = f'https://{company_domain}.zendesk.com/api/v2/users/search.json?query=email:{rec.email}'
search_response = requests.get(customer_search_url,
auth=(f"{company_email}/token",
api_key))
if search_response.status_code == 200:
results = search_response.json().get('users')
if results and len(results) > 0:
customer_id = results[0]['id']
else:
data = {
'user': {
'name': rec.customer_id.name,
'email': rec.email,
}
}
user_url = f'https://{company_domain}.zendesk.com/api/v2/users.json'
user_response = requests.post(user_url, json=data,
auth=(
f"{company_email}/token",
api_key),
headers=headers)
if user_response.status_code == 201:
customer_id = user_response.json().get('user').get(
'id')
else:
raise UserError(_(user_response.json()['error']))
data = {
'ticket': {'subject': rec.subject, 'priority': zen_prio,
'comment': {'body': rec.description},
'requester_id': customer_id}}
url = f'https://{company_domain}.zendesk.com/api/v2/tickets.json'
response = requests.post(url, data=json.dumps(data),
auth=(
f"{company_email}/token", api_key),
headers=headers)
if response.status_code != 201:
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': _("Error!"),
'message': _("Problem with exporting ticket to"
" Zendesk"),
'sticky': False,
}
}
if response.json().get("ticket"):
rec.zendesk_ticket_no = response.json()['ticket']['id']
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': _("Success!"),
'message': _("Tickets are exported successfully"),
'sticky': False,
}
}

82
odoo_zendesk_connector/models/res_config_settings.py

@ -0,0 +1,82 @@
# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
import requests
from odoo import fields, models, _
class ResConfigSettings(models.TransientModel):
"""This function is used to add some fields in Configuration setting that
helps to establish the connection, and also check whether the connection is
established or not"""
_inherit = 'res.config.settings'
is_connect_zendesk = fields.Boolean(string="Connect Zendesk",
help='Do you want to connect with '
'zendesk',
config_parameter='odoo_zendesk_connector.is_connect_zendesk')
company_domain = fields.Char(string='Company Domain',
help="Provide the domain of your company",
config_parameter=
'odoo_zendesk_connector.company_domain')
company_email = fields.Char(string='Company Email',
help='Email of your company',
config_parameter=
'odoo_zendesk_connector.company_email')
api_key = fields.Char(string='API', help='Generated api key',
config_parameter='odoo_zendesk_connector.api_key')
password = fields.Char(string='Password', help='Password of Zendesk '
'account',
config_parameter='odoo_zendesk_connector.password')
def action_test_connection(self):
"""This function is used to check whether the connection is
established or not"""
zendesk_email = self.company_email
zendesk_token = self.api_key
company_domain = self.company_domain
zendesk_url = f'https://{company_domain}.zendesk.com/api/v2/'
endpoint = 'tickets.json'
headers = {'Content-Type': 'application/json'}
auth = (zendesk_email + '/token', zendesk_token)
try:
response = requests.get(zendesk_url + endpoint, headers=headers,
auth=auth)
response.raise_for_status()
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': _("Connection Test Succeeded!"),
'message': _("Everything seems properly set up!"),
'sticky': False,
}
}
except requests.exceptions.HTTPError as error:
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': _('Error'),
'message': _(error),
'sticky': False,
}
}

214
odoo_zendesk_connector/models/ticket_helpdesk.py

@ -0,0 +1,214 @@
# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
import json
import requests
from odoo import fields, models, _
from odoo.exceptions import UserError
class TicketHelpdesk(models.Model):
"""In this class there are functions for create a ticket in to zendesk,
update a ticket, and delete a ticket from zendesk"""
_inherit = 'ticket.helpdesk'
zendesk_ticket_no = fields.Char(string='Zendesk Ticket Id',
help='Shows the Id of ticket in Zendesk',
readonly=True)
is_ticket_from_zendesk = fields.Boolean(string='Ticket From Zendesk',
help='Is this a ticket from'
' Zendesk')
email = fields.Char(string='Email', help='Shows the email of the customer',
required=True)
def action_create_to_zendesk(self):
"""This function will help to create a ticket in Zendesk"""
company_domain = self.env['ir.config_parameter'].sudo().get_param(
'odoo_zendesk_connector.company_domain')
company_email = self.env['ir.config_parameter'].sudo().get_param(
'odoo_zendesk_connector.company_email')
password = self.env['ir.config_parameter'].sudo().get_param(
'odoo_zendesk_connector.password')
api_token = self.env['ir.config_parameter'].sudo().get_param(
'odoo_zendesk_connector.api_key')
if self.zendesk_ticket_no:
zen_id_search_url = f'https://{company_domain}.zendesk.com/api/v2/tickets/{self.zendesk_ticket_no}.json'
zen_id_search_response = requests.get(zen_id_search_url,
timeout=180, auth=(
company_email, password))
if zen_id_search_response.status_code == 200:
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': _("Warning"),
'message': _("Ticket already exists"),
'sticky': False,
},
}
priority = {
'2': 'normal',
'3': 'high',
'4': 'urgent'
}
zen_prio = priority.get(self.priority, 'None')
headers = {'content-type': 'application/json'}
customer_search_url = f'https://{company_domain}.zendesk.com/api/v2/users/search.json?query=email:{self.email}'
search_response = requests.get(customer_search_url,
auth=(company_email, password),
timeout=20)
if search_response.status_code == 200:
results = search_response.json().get('users')
if not results:
# Customer does not exist, create a new user
data = {
'user': {
'name': self.customer_id.name,
'email': self.email,
}
}
user_url = f'https://{company_domain}.zendesk.com/api/v2/users.json'
user_response = requests.post(user_url, json=data,
auth=(company_email, password),
headers=headers)
if user_response.status_code != 201:
raise UserError(_(user_response.json()['error']))
data = {'ticket': {'subject': self.subject, 'priority': zen_prio,
'comment': {'body': self.description},
'requester': {
'name': self.customer_id.name,
'email': self.customer_id.email
}
}}
url = f'https://{company_domain}.zendesk.com/api/v2/tickets.json'
response = requests.post(url, data=json.dumps(data),
auth=(f"{company_email}/token", api_token),
headers=headers)
if response.status_code == 201:
self.zendesk_ticket_no = response.json()['ticket']['id']
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': _("Success!"),
'message': _("Successfully Created the ticket in Zendesk"),
'sticky': False,
}
}
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': _("Error!"),
'message': _(
"Creation of Zendesk ticket seems to have failed!"),
'sticky': False,
}
}
def action_update_zendesk_ticket(self):
"""This function is used to update a ticket from oddo"""
company_domain = self.env['ir.config_parameter'].sudo().get_param(
'odoo_zendesk_connector.company_domain')
company_email = self.env['ir.config_parameter'].sudo().get_param(
'odoo_zendesk_connector.company_email')
api_token=self.env['ir.config_parameter'].sudo().get_param('odoo_zendesk_connector.api_key')
zen_id = self.zendesk_ticket_no
priority = {
'1': 'low',
'2': 'normal',
'3': 'high',
'4': 'urgent'
}
zen_prio = 'None'
if self.priority in priority:
zen_prio = priority[self.priority]
data = {
'ticket': {
'comment': {'body': self.description},
'priority': zen_prio,
'subject': self.subject,
'requester': {
'name': self.customer_name, # Add the customer name field
'email': self.email # Add the customer email field
}
}
}
url = f'https://{company_domain}.zendesk.com/api/v2/tickets/{zen_id}.json'
headers = {'content-type': 'application/json'}
response = requests.put(url, data=json.dumps(data),
auth = (f"{company_email}/token", api_token),
headers=headers)
if response.status_code != 200:
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': _("Error!"),
'message': _("Updation of the ticket seems to be failed"),
'sticky': False,
}
}
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': _("Success!"),
'message': _("Successfully Updated the ticket"),
'sticky': False,
}
}
def action_delete_zendesk_ticket(self):
"""This function is used to delete a ticket from zendesk"""
company_domain = self.env['ir.config_parameter'].sudo().get_param(
'odoo_zendesk_connector.company_domain')
company_email = self.env['ir.config_parameter'].sudo().get_param(
'odoo_zendesk_connector.company_email')
api_token = self.env['ir.config_parameter'].sudo().get_param(
'odoo_zendesk_connector.api_key')
zendesk_id = self.zendesk_ticket_no
headers = {'Content-Type': 'application/json'}
url = f'https://{company_domain}.zendesk.com/api/v2/tickets/{zendesk_id}.json'
response = requests.delete(url, auth=(f"{company_email}/token", api_token),
headers=headers, timeout=180)
if response.status_code == 204:
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': _("Success!"),
'message': _("Successfully deleted the tickets"),
'sticky': False,
}
}
else:
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': _("Error"),
'message': _("Have issues with deleting the ticket"),
'sticky': False,
}
}

3
odoo_zendesk_connector/security/ir.model.access.csv

@ -0,0 +1,3 @@
id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
access_help_ticket,access.ticket.helpdesk,odoo_website_helpdesk.model_ticket_helpdesk,base.group_user,1,1,1,1
access_import_export_ticket,access.import.export.ticket,model_import_export_ticket,base.group_user,1,1,1,1
1 id name model_id/id group_id/id perm_read perm_write perm_create perm_unlink
2 access_help_ticket access.ticket.helpdesk odoo_website_helpdesk.model_ticket_helpdesk base.group_user 1 1 1 1
3 access_import_export_ticket access.import.export.ticket model_import_export_ticket base.group_user 1 1 1 1

BIN
odoo_zendesk_connector/static/description/assets/icons/check.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
odoo_zendesk_connector/static/description/assets/icons/chevron.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

BIN
odoo_zendesk_connector/static/description/assets/icons/cogs.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
odoo_zendesk_connector/static/description/assets/icons/consultation.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
odoo_zendesk_connector/static/description/assets/icons/ecom-black.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 576 B

BIN
odoo_zendesk_connector/static/description/assets/icons/education-black.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 733 B

BIN
odoo_zendesk_connector/static/description/assets/icons/hotel-black.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 911 B

BIN
odoo_zendesk_connector/static/description/assets/icons/license.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
odoo_zendesk_connector/static/description/assets/icons/lifebuoy.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
odoo_zendesk_connector/static/description/assets/icons/manufacturing-black.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

BIN
odoo_zendesk_connector/static/description/assets/icons/pos-black.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 878 B

BIN
odoo_zendesk_connector/static/description/assets/icons/puzzle.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 653 B

BIN
odoo_zendesk_connector/static/description/assets/icons/restaurant-black.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 905 B

BIN
odoo_zendesk_connector/static/description/assets/icons/service-black.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 839 B

BIN
odoo_zendesk_connector/static/description/assets/icons/trading-black.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 B

BIN
odoo_zendesk_connector/static/description/assets/icons/training.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 627 B

BIN
odoo_zendesk_connector/static/description/assets/icons/update.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
odoo_zendesk_connector/static/description/assets/icons/user.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 988 B

BIN
odoo_zendesk_connector/static/description/assets/icons/wrench.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
odoo_zendesk_connector/static/description/assets/misc/Cybrosys R.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

BIN
odoo_zendesk_connector/static/description/assets/misc/categories.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
odoo_zendesk_connector/static/description/assets/misc/check-box.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
odoo_zendesk_connector/static/description/assets/misc/compass.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
odoo_zendesk_connector/static/description/assets/misc/corporate.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
odoo_zendesk_connector/static/description/assets/misc/customer-support.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
odoo_zendesk_connector/static/description/assets/misc/cybrosys-logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

BIN
odoo_zendesk_connector/static/description/assets/misc/features.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 B

BIN
odoo_zendesk_connector/static/description/assets/misc/logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

BIN
odoo_zendesk_connector/static/description/assets/misc/pictures.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
odoo_zendesk_connector/static/description/assets/misc/pie-chart.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
odoo_zendesk_connector/static/description/assets/misc/right-arrow.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 967 B

BIN
odoo_zendesk_connector/static/description/assets/misc/star.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
odoo_zendesk_connector/static/description/assets/misc/support.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
odoo_zendesk_connector/static/description/assets/misc/whatsapp.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

BIN
odoo_zendesk_connector/static/description/assets/modules/1.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

BIN
odoo_zendesk_connector/static/description/assets/modules/3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

BIN
odoo_zendesk_connector/static/description/assets/modules/4.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

BIN
odoo_zendesk_connector/static/description/assets/modules/5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

BIN
odoo_zendesk_connector/static/description/assets/modules/6.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

BIN
odoo_zendesk_connector/static/description/assets/modules/banner.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 912 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/hero.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/oz0018.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/oz0019.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/oz1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/oz13.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/oz16.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/oz17.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/oz2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/oz3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/oz4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/oz5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/oz8.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/zendesk-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/zendesk-10.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/zendesk-11.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/zendesk-12.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/zendesk-13.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/zendesk-14.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/zendesk-15.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/zendesk-16.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/zendesk-17.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/zendesk-2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/zendesk-3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/zendesk-4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/zendesk-5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/zendesk-6.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/zendesk-7.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/zendesk-8.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

BIN
odoo_zendesk_connector/static/description/assets/screenshots/zendesk-9.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

BIN
odoo_zendesk_connector/static/description/banner.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

BIN
odoo_zendesk_connector/static/description/icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

1138
odoo_zendesk_connector/static/description/index.html

File diff suppressed because it is too large

44
odoo_zendesk_connector/views/import_export_ticket_views.xml

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- Form view of the model import.export.ticket-->
<record id="import_export_ticket_view_form" model="ir.ui.view">
<field name="name">import.export.ticket.view.form</field>
<field name="model">import.export.ticket</field>
<field name="arch" type="xml">
<form>
<sheet>
<group col="5">
<group colspan="2">
<field name="start_date"/>
<field name="end_date"/>
<footer>
<button class="oe_highlight" name="action_import_tickets" string="Import" type="object"/>
<button class="oe_highlight" name="action_export_tickets" string="Export" type="object"/>
</footer>
</group>
</group>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids"/>
<field name="message_ids"/>
</div>
</form>
</field>
</record>
<!-- Action of the model import.export.ticket-->
<record id="import_export_ticket_action" model="ir.actions.act_window">
<field name="name">Import/Export Tickets</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">import.export.ticket</field>
<field name="view_mode">form</field>
<field name="view_id" ref="import_export_ticket_view_form"/>
<field name="target">new</field>
</record>
<!-- Menu for importing and exporting tickets-->
<menuitem
id="import_export_ticket_menu"
name="Import/Export Tickets"
action="import_export_ticket_action"
parent="odoo_website_helpdesk.menu_helpdesk_configuration"
sequence="1"/>
</odoo>

77
odoo_zendesk_connector/views/res_config_settings_views.xml

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- Inherited the form view of res.config.settings and add some fields for
giving the credentials of zendesk-->
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit.odoo.zendesk.connector</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="base.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@data-key='helpdesk_ticket']" position="inside">
<h2>Connect Zendesk</h2>
<div class="row mt16 o_settings_container">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="is_connect_zendesk"/>
</div>
<div class="o_setting_right_pane">
<label for="is_connect_zendesk"/>
</div>
</div>
</div>
<div class="row mt16 o_settings_container">
<div class="col-12 col-lg-6 o_setting_box"
invisible="is_connect_zendesk == False">
<div class="o_setting_right_pane">
<label for="company_domain"/>
<div class="content-group">
<div class="mt16">
<field name="company_domain"/>
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box"
invisible="is_connect_zendesk==False">
<div class="o_setting_right_pane">
<label for="company_email"/>
<div class="content-group">
<div class="mt16">
<field name="company_email"/>
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box"
invisible="is_connect_zendesk== False">
<div class="o_setting_right_pane">
<label for="api_key"/>
<div class="content-group">
<div class="mt16">
<field name="api_key"/>
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box"
invisible="is_connect_zendesk ==False">
<div class="o_setting_right_pane">
<label for="password"/>
<div class="content-group">
<div class="mt16">
<field name="password" password="True"/>
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_right_pane">
<button class="oe_highlight" name="action_test_connection" string="Test Connection" type="object"
invisible="is_connect_zendesk== False"/>
</div>
</div>
</div>
</xpath>
</field>
</record>
</odoo>

26
odoo_zendesk_connector/views/ticket_helpdesk_views.xml

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- Inherited the form view of help.ticket and to add some fields and some button-->
<record id="ticket_helpdesk_view_form" model="ir.ui.view">
<field name="name">ticket.helpdesk.view.form.inherit.odoo.zendesk.connector</field>
<field name="model">ticket.helpdesk</field>
<field name="inherit_id" ref="odoo_website_helpdesk.ticket_helpdesk_view_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='email']" position="attributes">
<attribute name="required">1</attribute>
</xpath>
<field name="end_date" position="after">
<field name="zendesk_ticket_no"/>
<field name="is_ticket_from_zendesk" invisible="1"/>
</field>
<xpath expr="//header" position="inside">
<button string="Create to Zendesk"
type="object" name="action_create_to_zendesk"/>
<button string="Update"
type="object" name="action_update_zendesk_ticket"/>
<button string="Delete From Zendesk"
type="object" name="action_delete_zendesk_ticket"/>
</xpath>
</field>
</record>
</odoo>
Loading…
Cancel
Save