@ -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>`__ |
@ -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 |
@ -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 |
|||
} |
@ -0,0 +1,5 @@ |
|||
## Module <odoo_zendesk_connector> |
|||
#### 22.07.2024 |
|||
#### Version 17.0.1.0.0 |
|||
##### ADD |
|||
- Initial Commit for Odoo Zendesk Connector |
@ -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 |
@ -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, |
|||
} |
|||
} |
|||
|
@ -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, |
|||
} |
|||
} |
@ -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, |
|||
} |
|||
} |
|
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 310 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 576 B |
After Width: | Height: | Size: 733 B |
After Width: | Height: | Size: 911 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 673 B |
After Width: | Height: | Size: 878 B |
After Width: | Height: | Size: 653 B |
After Width: | Height: | Size: 905 B |
After Width: | Height: | Size: 839 B |
After Width: | Height: | Size: 427 B |
After Width: | Height: | Size: 627 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 988 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 80 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 589 B |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 967 B |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 81 KiB |
After Width: | Height: | Size: 87 KiB |
After Width: | Height: | Size: 76 KiB |
After Width: | Height: | Size: 79 KiB |
After Width: | Height: | Size: 88 KiB |
After Width: | Height: | Size: 912 KiB |
After Width: | Height: | Size: 135 KiB |
After Width: | Height: | Size: 55 KiB |
After Width: | Height: | Size: 74 KiB |
After Width: | Height: | Size: 260 KiB |
After Width: | Height: | Size: 57 KiB |
After Width: | Height: | Size: 90 KiB |
After Width: | Height: | Size: 162 KiB |
After Width: | Height: | Size: 236 KiB |
After Width: | Height: | Size: 147 KiB |
After Width: | Height: | Size: 115 KiB |
After Width: | Height: | Size: 148 KiB |
After Width: | Height: | Size: 87 KiB |
After Width: | Height: | Size: 88 KiB |
After Width: | Height: | Size: 101 KiB |
After Width: | Height: | Size: 115 KiB |
After Width: | Height: | Size: 100 KiB |
After Width: | Height: | Size: 104 KiB |
After Width: | Height: | Size: 92 KiB |
After Width: | Height: | Size: 90 KiB |
After Width: | Height: | Size: 88 KiB |
After Width: | Height: | Size: 180 KiB |
After Width: | Height: | Size: 91 KiB |
After Width: | Height: | Size: 94 KiB |
After Width: | Height: | Size: 179 KiB |
After Width: | Height: | Size: 90 KiB |
After Width: | Height: | Size: 96 KiB |
After Width: | Height: | Size: 179 KiB |
After Width: | Height: | Size: 100 KiB |
After Width: | Height: | Size: 98 KiB |
After Width: | Height: | Size: 85 KiB |
After Width: | Height: | Size: 7.1 KiB |
@ -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> |
@ -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> |
@ -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> |