diff --git a/chatgpt_odoo_connector/README.rst b/chatgpt_odoo_connector/README.rst new file mode 100644 index 000000000..8c0a766ad --- /dev/null +++ b/chatgpt_odoo_connector/README.rst @@ -0,0 +1,52 @@ +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg + :target: https://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +ChatGPT Odoo Connector +====================== +This module simplifies content creation and editing by integrating ChatGPT. +It also facilitates the generation of images for newly created products and +when modifying product names. Additionally, it includes a Speech-to-Text feature +that allows users to convert spoken language into written text, making hands-free +interaction possible and further streamlining the content creation process. + +Configuration +============= +The user should install 'openai' for Python by running: +'sudo pip install openai' for authorization code flow. + +Company +------- +* `Cybrosys Techno Solutions `__ + +License +------- +Affero General Public License, Version 3 (AGPL v3). +(https://www.gnu.org/licenses/agpl-3.0-standalone.html) + +Credits +------- +Developer: (V16) Ashwin A, Contact: odoo@cybrosys.com + +Contacts +-------- +* Mail Contact : odoo@cybrosys.com +* Website : https://cybrosys.com + +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 `Our Website `__ + +Further information +=================== +HTML Description: ``__ \ No newline at end of file diff --git a/chatgpt_odoo_connector/__init__.py b/chatgpt_odoo_connector/__init__.py new file mode 100644 index 000000000..512819c2d --- /dev/null +++ b/chatgpt_odoo_connector/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# +from . import controllers +from . import models diff --git a/chatgpt_odoo_connector/__manifest__.py b/chatgpt_odoo_connector/__manifest__.py new file mode 100644 index 000000000..8f21b855d --- /dev/null +++ b/chatgpt_odoo_connector/__manifest__.py @@ -0,0 +1,63 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# +{ + "name": "ChatGPT Odoo Connector", + "version": "16.0.1.0.0", + "category": "Productivity, Extra Tools ", + "summary": "User can create content, Generate product image and Convert spoken language into written text using AI.", + "description": """ This module simplifies content creation and editing by integrating ChatGPT. + It also facilitates the generation of images for newly created products and + when modifying product names. Additionally, it includes a Speech-to-Text feature + that allows users to convert spoken language into written text, making hands-free + interaction possible and further streamlining the content creation process.""", + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': "https://www.cybrosys.com", + 'depends': ['mail', 'product', 'web_editor'], + 'data': [ + 'security/ir.model.access.csv', + 'views/res_config_settings_views.xml', + 'views/product_template.xml', + 'views/product_product.xml', + ], + 'assets': { + 'web_editor.assets_wysiwyg': [ + 'chatgpt_odoo_connector/static/src/xml/web_editor_toolbar.xml', + 'chatgpt_odoo_connector/static/src/xml/alternative_chatgpt.xml', + ], + 'web.assets_backend': [ + 'chatgpt_odoo_connector/static/src/css/chatgpt_odoo.css', + 'chatgpt_odoo_connector/static/src/js/wysiwyg.js', + 'chatgpt_odoo_connector/static/src/js/open_chatgpt.js', + 'chatgpt_odoo_connector/static/src/js/recordAudio.js', + 'chatgpt_odoo_connector/static/src/js/custom_toolbar.js', + 'chatgpt_odoo_connector/static/src/js/alternative_chatgpt.js', + ], + }, + 'external_dependencies': {'python': ['openai']}, + 'images': ['static/description/banner.png'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/chatgpt_odoo_connector/controllers/__init__.py b/chatgpt_odoo_connector/controllers/__init__.py new file mode 100644 index 000000000..f23513e1d --- /dev/null +++ b/chatgpt_odoo_connector/controllers/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# +from . import chatgpt_odoo_connector diff --git a/chatgpt_odoo_connector/controllers/chatgpt_odoo_connector.py b/chatgpt_odoo_connector/controllers/chatgpt_odoo_connector.py new file mode 100644 index 000000000..46710656d --- /dev/null +++ b/chatgpt_odoo_connector/controllers/chatgpt_odoo_connector.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# +from odoo import http +from pathlib import Path +from odoo.http import request +import os +from odoo.tools import json + + +class SpeechToText(http.Controller): + @http.route('/upload_audio', type='http', auth='public', methods=['POST'], csrf=False) + def upload_audio(self, **kwargs): + """ + Function for uploading audio file into a file and + returns the path of the file as json format + """ + upload_dir = Path(__file__).parent + file = kwargs.get('file') + if file: + file_path = os.path.join(upload_dir, file.filename) + with open(file_path, 'wb') as f: + f.write(file.read()) + return request.make_response(json.dumps({'filePath': file_path}), headers={'Content-Type': 'application/json'}) + return request.make_response(json.dumps({'error': 'No file uploaded'}), headers={'Content-Type': 'application/json'}) diff --git a/chatgpt_odoo_connector/doc/RELEASE_NOTES.md b/chatgpt_odoo_connector/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..b6162275a --- /dev/null +++ b/chatgpt_odoo_connector/doc/RELEASE_NOTES.md @@ -0,0 +1,8 @@ +## Module + +#### 27.05.2024 +#### Version 16.0.1.0.0 +#### ADD + +- Initial commit for ChatGPT Odoo Connector + diff --git a/chatgpt_odoo_connector/models/__init__.py b/chatgpt_odoo_connector/models/__init__.py new file mode 100644 index 000000000..1f2ee65a6 --- /dev/null +++ b/chatgpt_odoo_connector/models/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# +from . import open_chatgpt +from . import product_product +from . import product_template +from . import res_config_settings diff --git a/chatgpt_odoo_connector/models/open_chatgpt.py b/chatgpt_odoo_connector/models/open_chatgpt.py new file mode 100644 index 000000000..1e0023aee --- /dev/null +++ b/chatgpt_odoo_connector/models/open_chatgpt.py @@ -0,0 +1,91 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# +from os import remove +from openai import OpenAI +from odoo import api, models + + +class ChatGPTOdoo(models.Model): + _name = 'open.chatgpt' + _description = 'Open ChatGPT' + + @api.model + def get_response(self, message): + """Function for getting response based on the message.""" + api_key = self.env['ir.config_parameter'].sudo().get_param('chatgpt_odoo_connector.api_key') + client = OpenAI(api_key=api_key) + try: + chat_completion = client.chat.completions.create( + messages=[ + { + "role": "user", + "content": message, + } + ], + model="gpt-3.5-turbo", + ) + except Exception as e: + message = str(e).split("'message':")[1] + error_message = message.split(", 'type':")[0] + return error_message + return chat_completion.choices[0].message.content + + @api.model + def edit_content(self, message, message_type): + """Function for editing(shortening, lengthening, and rephrasing) the description """ + api_key = self.env['ir.config_parameter'].sudo().get_param( + 'chatgpt_odoo_connector.api_key') + client = OpenAI(api_key=api_key) + try: + chat_completion = client.chat.completions.create( + messages=[ + { + "role": "user", + "content": f"{message_type}: {message}", + } + ], + model="gpt-3.5-turbo", + ) + except Exception as e: + message = str(e).split("'message':")[1] + error_message = message.split(", 'type':")[0] + return error_message + return chat_completion.choices[0].message.content + + @api.model + def convert_to_text(self, audio_path): + """ Function for converting the audio from the file into text using AI. + It returns the text. + """ + api_key = self.env['ir.config_parameter'].sudo().get_param( + 'chatgpt_odoo_connector.api_key') + client = OpenAI(api_key=api_key) + try: + audio_file = open(audio_path, "rb") + transcription = client.audio.transcriptions.create( + model="whisper-1", + file=audio_file + ) + remove(audio_path) + except Exception as e: + return f'Error: {str(e)}' + return transcription.text diff --git a/chatgpt_odoo_connector/models/product_product.py b/chatgpt_odoo_connector/models/product_product.py new file mode 100644 index 000000000..de5797cc7 --- /dev/null +++ b/chatgpt_odoo_connector/models/product_product.py @@ -0,0 +1,91 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# +import base64 +import requests +from openai import OpenAI +from odoo import api, fields, models + + +class ProductProduct(models.Model): + _inherit = 'product.product' + + is_create_image = fields.Boolean(related='product_tmpl_id.is_create_image', + string='Generate Image', + readonly=False, + help='Check this box if you want to automatically generate an image for this product') + + is_update_image = fields.Boolean(related='product_tmpl_id.is_update_image', + string='Update Image', + readonly=False, + help='Check this box if you want to automatically update an image for this product while changing the name.') + + @api.model + def create(self, vals): + """ Method for generating images for product """ + res = super(ProductProduct, self).create(vals) + if not res.image_1920 and res.is_create_image: + image_base64 = self.generate_image(res.name) + if image_base64: + res.write({ + 'image_1920': image_base64, + }) + else: + res.message_post( + body="Failed to generate image for product: '%s' due to 'Incorrect API key provided or Other issues. You can find your API key at https://platform.openai.com/account/api-keys." % res.name, + message_type='notification') + return res + + def write(self, vals): + """ Method for updating image if name of the product updates""" + if 'name' in vals and 'image_1920' not in vals: + is_update_image = vals.get('is_update_image', self.is_update_image) + if is_update_image: + image_base64 = self.generate_image(vals['name']) + if image_base64: + vals['image_1920'] = image_base64 + else: + self.message_post( + body="Failed to update image for product: '%s' due to 'Incorrect API key provided or Other issues. You can find your API key at https://platform.openai.com/account/api-keys." % + vals['name'], + message_type='notification') + return super(ProductProduct, self).write(vals) + + def generate_image(self, name): + """ Function for generating images with the help of AI based on the name + of the product""" + api_key = self.env['ir.config_parameter'].sudo().get_param( + 'chatgpt_odoo_connector.api_key') + client = OpenAI(api_key=api_key) + try: + response = client.images.generate( + model="dall-e-3", + prompt=name, + size="1024x1024", + quality="standard", + n=1, + ) + image_url = response.data[0].url + response = requests.get(image_url) + image_base64 = base64.b64encode(response.content) + except: + return None + return image_base64 diff --git a/chatgpt_odoo_connector/models/product_template.py b/chatgpt_odoo_connector/models/product_template.py new file mode 100644 index 000000000..d4d88606f --- /dev/null +++ b/chatgpt_odoo_connector/models/product_template.py @@ -0,0 +1,88 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# +import base64 +import requests +from openai import OpenAI +from odoo import api, fields, models + + +class ProductTemplate(models.Model): + _inherit = 'product.template' + + is_create_image = fields.Boolean(string='Generate Image', + default=True, + help='Check this box if you want to automatically generate an image for this product') + + is_update_image = fields.Boolean(string='Update Image', + help='Check this box if you want to automatically update an image for this product while changing the name.') + + @api.model + def create(self, vals): + """ Method for generating images for product """ + res = super(ProductTemplate, self).create(vals) + if not res.image_1920 and res.is_create_image: + image_base64 = self.generate_image(res.name) + if image_base64: + res.write({ + 'image_1920': image_base64, + }) + else: + res.message_post( + body="Failed to generate image for product: '%s' due to 'Incorrect API key provided or Other issues. You can find your API key at https://platform.openai.com/account/api-keys." % res.name, + message_type='notification') + return res + + def write(self, vals): + """ Method for updating image if name of the product updates""" + if 'name' in vals and 'image_1920' not in vals: + is_update_image = vals.get('is_update_image', self.is_update_image) + if is_update_image: + image_base64 = self.generate_image(vals['name']) + if image_base64: + vals['image_1920'] = image_base64 + else: + self.message_post( + body="Failed to update image for product: '%s' due to 'Incorrect API key provided or Other issues. You can find your API key at https://platform.openai.com/account/api-keys." % + vals['name'], + message_type='notification') + return super(ProductTemplate, self).write(vals) + + def generate_image(self, name): + """ Function for generating images with the help of AI based on the name + of the product""" + api_key = self.env['ir.config_parameter'].sudo().get_param( + 'chatgpt_odoo_connector.api_key') + client = OpenAI(api_key=api_key) + try: + response = client.images.generate( + model="dall-e-3", + prompt=name, + size="1024x1024", + quality="standard", + n=1, + ) + image_url = response.data[0].url + response = requests.get(image_url) + image_base64 = base64.b64encode(response.content) + except: + return None + return image_base64 diff --git a/chatgpt_odoo_connector/models/res_config_settings.py b/chatgpt_odoo_connector/models/res_config_settings.py new file mode 100644 index 000000000..403c53c29 --- /dev/null +++ b/chatgpt_odoo_connector/models/res_config_settings.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + """Add field to configuration settings""" + _inherit = "res.config.settings" + + api_key = fields.Char(string="API Key", help="Provide the API Key here", + config_parameter="chatgpt_odoo_connector.api_key") diff --git a/chatgpt_odoo_connector/security/ir.model.access.csv b/chatgpt_odoo_connector/security/ir.model.access.csv new file mode 100644 index 000000000..2154d062f --- /dev/null +++ b/chatgpt_odoo_connector/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink +access_open_chatgpt,access.open.chatgpt,model_open_chatgpt,base.group_user,1,1,1,1 diff --git a/chatgpt_odoo_connector/static/description/assets/icons/chatgpt.png b/chatgpt_odoo_connector/static/description/assets/icons/chatgpt.png new file mode 100644 index 000000000..20a03f9d4 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/icons/chatgpt.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/icons/check.png b/chatgpt_odoo_connector/static/description/assets/icons/check.png new file mode 100755 index 000000000..c8e85f51d Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/icons/check.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/icons/chevron.png b/chatgpt_odoo_connector/static/description/assets/icons/chevron.png new file mode 100755 index 000000000..2089293d6 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/icons/chevron.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/icons/close.png b/chatgpt_odoo_connector/static/description/assets/icons/close.png new file mode 100644 index 000000000..f82fed32d Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/icons/close.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/icons/cogs.png b/chatgpt_odoo_connector/static/description/assets/icons/cogs.png new file mode 100755 index 000000000..95d0bad62 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/icons/cogs.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/icons/consultation.png b/chatgpt_odoo_connector/static/description/assets/icons/consultation.png new file mode 100755 index 000000000..8319d4baa Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/icons/consultation.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/icons/ecom-black.png b/chatgpt_odoo_connector/static/description/assets/icons/ecom-black.png new file mode 100755 index 000000000..a9385ff13 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/icons/ecom-black.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/icons/education-black.png b/chatgpt_odoo_connector/static/description/assets/icons/education-black.png new file mode 100755 index 000000000..3eb09b27b Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/icons/education-black.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/icons/hotel-black.png b/chatgpt_odoo_connector/static/description/assets/icons/hotel-black.png new file mode 100755 index 000000000..130f613be Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/icons/hotel-black.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/icons/license.png b/chatgpt_odoo_connector/static/description/assets/icons/license.png new file mode 100755 index 000000000..a5869797e Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/icons/license.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/icons/lifebuoy.png b/chatgpt_odoo_connector/static/description/assets/icons/lifebuoy.png new file mode 100755 index 000000000..658d56ccc Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/icons/lifebuoy.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/icons/manufacturing-black.png b/chatgpt_odoo_connector/static/description/assets/icons/manufacturing-black.png new file mode 100755 index 000000000..697eb0e9f Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/icons/manufacturing-black.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/icons/pos-black.png b/chatgpt_odoo_connector/static/description/assets/icons/pos-black.png new file mode 100755 index 000000000..97c0f90c1 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/icons/pos-black.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/icons/puzzle.png b/chatgpt_odoo_connector/static/description/assets/icons/puzzle.png new file mode 100755 index 000000000..65cf854e7 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/icons/puzzle.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/icons/restaurant-black.png b/chatgpt_odoo_connector/static/description/assets/icons/restaurant-black.png new file mode 100755 index 000000000..4a35eb939 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/icons/restaurant-black.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/icons/service-black.png b/chatgpt_odoo_connector/static/description/assets/icons/service-black.png new file mode 100755 index 000000000..301ab51cb Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/icons/service-black.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/icons/trading-black.png b/chatgpt_odoo_connector/static/description/assets/icons/trading-black.png new file mode 100755 index 000000000..9398ba2f1 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/icons/trading-black.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/icons/training.png b/chatgpt_odoo_connector/static/description/assets/icons/training.png new file mode 100755 index 000000000..884ca024d Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/icons/training.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/icons/update.png b/chatgpt_odoo_connector/static/description/assets/icons/update.png new file mode 100755 index 000000000..ecbc5a01a Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/icons/update.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/icons/user.png b/chatgpt_odoo_connector/static/description/assets/icons/user.png new file mode 100755 index 000000000..6ffb23d9f Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/icons/user.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/icons/wrench.png b/chatgpt_odoo_connector/static/description/assets/icons/wrench.png new file mode 100755 index 000000000..6c04dea0f Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/icons/wrench.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/misc/categories.png b/chatgpt_odoo_connector/static/description/assets/misc/categories.png new file mode 100644 index 000000000..bedf1e0b1 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/misc/categories.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/misc/check-box.png b/chatgpt_odoo_connector/static/description/assets/misc/check-box.png new file mode 100644 index 000000000..42caf24b9 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/misc/check-box.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/misc/compass.png b/chatgpt_odoo_connector/static/description/assets/misc/compass.png new file mode 100644 index 000000000..d5fed8faa Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/misc/compass.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/misc/corporate.png b/chatgpt_odoo_connector/static/description/assets/misc/corporate.png new file mode 100644 index 000000000..2eb13edbf Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/misc/corporate.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/misc/customer-support.png b/chatgpt_odoo_connector/static/description/assets/misc/customer-support.png new file mode 100644 index 000000000..79efc72ed Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/misc/customer-support.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/misc/cybrosys-logo.png b/chatgpt_odoo_connector/static/description/assets/misc/cybrosys-logo.png new file mode 100644 index 000000000..cc3cc0ccf Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/misc/cybrosys-logo.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/misc/features.png b/chatgpt_odoo_connector/static/description/assets/misc/features.png new file mode 100644 index 000000000..b41769f77 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/misc/features.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/misc/logo.png b/chatgpt_odoo_connector/static/description/assets/misc/logo.png new file mode 100644 index 000000000..478462d3e Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/misc/logo.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/misc/pictures.png b/chatgpt_odoo_connector/static/description/assets/misc/pictures.png new file mode 100644 index 000000000..56d255fe9 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/misc/pictures.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/misc/pie-chart.png b/chatgpt_odoo_connector/static/description/assets/misc/pie-chart.png new file mode 100644 index 000000000..426e05244 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/misc/pie-chart.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/misc/right-arrow.png b/chatgpt_odoo_connector/static/description/assets/misc/right-arrow.png new file mode 100644 index 000000000..730984a06 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/misc/right-arrow.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/misc/star.png b/chatgpt_odoo_connector/static/description/assets/misc/star.png new file mode 100644 index 000000000..2eb9ab29f Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/misc/star.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/misc/support.png b/chatgpt_odoo_connector/static/description/assets/misc/support.png new file mode 100644 index 000000000..4f18b8b82 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/misc/support.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/misc/whatsapp.png b/chatgpt_odoo_connector/static/description/assets/misc/whatsapp.png new file mode 100644 index 000000000..d513a5356 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/misc/whatsapp.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/modules/1.png b/chatgpt_odoo_connector/static/description/assets/modules/1.png new file mode 100644 index 000000000..2c8fbb83f Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/modules/1.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/modules/2.png b/chatgpt_odoo_connector/static/description/assets/modules/2.png new file mode 100644 index 000000000..f3c986fc1 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/modules/2.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/modules/3.png b/chatgpt_odoo_connector/static/description/assets/modules/3.png new file mode 100644 index 000000000..eb3f8652f Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/modules/3.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/modules/4.png b/chatgpt_odoo_connector/static/description/assets/modules/4.png new file mode 100644 index 000000000..99298bf4b Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/modules/4.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/modules/5.png b/chatgpt_odoo_connector/static/description/assets/modules/5.png new file mode 100644 index 000000000..faa759b4a Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/modules/5.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/modules/6.png b/chatgpt_odoo_connector/static/description/assets/modules/6.png new file mode 100644 index 000000000..63031e083 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/modules/6.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/screenshots/1.png b/chatgpt_odoo_connector/static/description/assets/screenshots/1.png new file mode 100644 index 000000000..0f57ccdf4 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/screenshots/1.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/screenshots/10.png b/chatgpt_odoo_connector/static/description/assets/screenshots/10.png new file mode 100644 index 000000000..1cedf9c05 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/screenshots/10.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/screenshots/11.png b/chatgpt_odoo_connector/static/description/assets/screenshots/11.png new file mode 100644 index 000000000..e8f1e3dde Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/screenshots/11.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/screenshots/12.png b/chatgpt_odoo_connector/static/description/assets/screenshots/12.png new file mode 100644 index 000000000..fc9229212 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/screenshots/12.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/screenshots/13.png b/chatgpt_odoo_connector/static/description/assets/screenshots/13.png new file mode 100644 index 000000000..deea6e1c0 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/screenshots/13.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/screenshots/14.png b/chatgpt_odoo_connector/static/description/assets/screenshots/14.png new file mode 100644 index 000000000..8e04737ad Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/screenshots/14.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/screenshots/15.png b/chatgpt_odoo_connector/static/description/assets/screenshots/15.png new file mode 100644 index 000000000..79c55470c Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/screenshots/15.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/screenshots/16.png b/chatgpt_odoo_connector/static/description/assets/screenshots/16.png new file mode 100644 index 000000000..5eace2f25 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/screenshots/16.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/screenshots/17.png b/chatgpt_odoo_connector/static/description/assets/screenshots/17.png new file mode 100644 index 000000000..ffd4617dd Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/screenshots/17.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/screenshots/18.png b/chatgpt_odoo_connector/static/description/assets/screenshots/18.png new file mode 100644 index 000000000..bbc9a66ea Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/screenshots/18.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/screenshots/19.png b/chatgpt_odoo_connector/static/description/assets/screenshots/19.png new file mode 100644 index 000000000..77cfe235f Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/screenshots/19.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/screenshots/2.png b/chatgpt_odoo_connector/static/description/assets/screenshots/2.png new file mode 100644 index 000000000..c0d4ea654 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/screenshots/2.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/screenshots/20.png b/chatgpt_odoo_connector/static/description/assets/screenshots/20.png new file mode 100644 index 000000000..d62768d9d Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/screenshots/20.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/screenshots/21.png b/chatgpt_odoo_connector/static/description/assets/screenshots/21.png new file mode 100644 index 000000000..a0e82a06b Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/screenshots/21.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/screenshots/3.png b/chatgpt_odoo_connector/static/description/assets/screenshots/3.png new file mode 100644 index 000000000..5ebe30831 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/screenshots/3.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/screenshots/4.png b/chatgpt_odoo_connector/static/description/assets/screenshots/4.png new file mode 100644 index 000000000..c93c1c5c9 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/screenshots/4.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/screenshots/5.png b/chatgpt_odoo_connector/static/description/assets/screenshots/5.png new file mode 100644 index 000000000..c4dbbbf09 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/screenshots/5.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/screenshots/6.png b/chatgpt_odoo_connector/static/description/assets/screenshots/6.png new file mode 100644 index 000000000..f9433f2d5 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/screenshots/6.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/screenshots/7.png b/chatgpt_odoo_connector/static/description/assets/screenshots/7.png new file mode 100644 index 000000000..75951c163 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/screenshots/7.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/screenshots/8.png b/chatgpt_odoo_connector/static/description/assets/screenshots/8.png new file mode 100644 index 000000000..5c24ec928 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/screenshots/8.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/screenshots/9.png b/chatgpt_odoo_connector/static/description/assets/screenshots/9.png new file mode 100644 index 000000000..c8d516f92 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/screenshots/9.png differ diff --git a/chatgpt_odoo_connector/static/description/assets/screenshots/hero.gif b/chatgpt_odoo_connector/static/description/assets/screenshots/hero.gif new file mode 100644 index 000000000..f9acb16c4 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/assets/screenshots/hero.gif differ diff --git a/chatgpt_odoo_connector/static/description/banner.png b/chatgpt_odoo_connector/static/description/banner.png new file mode 100644 index 000000000..e8082f79b Binary files /dev/null and b/chatgpt_odoo_connector/static/description/banner.png differ diff --git a/chatgpt_odoo_connector/static/description/icon.png b/chatgpt_odoo_connector/static/description/icon.png new file mode 100644 index 000000000..ed25bcf04 Binary files /dev/null and b/chatgpt_odoo_connector/static/description/icon.png differ diff --git a/chatgpt_odoo_connector/static/description/index.html b/chatgpt_odoo_connector/static/description/index.html new file mode 100644 index 000000000..3b52855b0 --- /dev/null +++ b/chatgpt_odoo_connector/static/description/index.html @@ -0,0 +1,752 @@ +
+ +
+ +
+
+ Community +
+
+ Enterprise +
+
+
+ +
+
+
+

+ ChatGPT Odoo Connector +

+

+ User can create content, Generate product image and Convert + spoken language into written text using AI +

+ + +
+
+
+ +
+ + +
+
+ +
+

+ Explore This + Module

+
+ + + + +
+
+ +
+

+ Overview +

+
+
+
+ This module simplifies content creation and editing by integrating ChatGPT. + It also facilitates the generation of images for newly created products and + when modifying product names. Additionally, it includes a Speech-to-Text feature + that allows users to convert spoken language into written text, making hands-free + interaction possible and further streamlining the content creation process. +
+
+ + + +
+
+ +
+

+ Features +

+
+
+
+ +
+ + Available in Odoo 16.0 Community & Enterprise +
+
+ + Easy to Set Up API Key of the ChatGPT +
+
+ + Accessing questions and answers directly from the Odoo interface is as easy as interacting with ChatGPT +
+
+ + Image generation for products using AI +
+
+ + Speech to Text feature for hands-free interaction +
+
+ + Speech to Text feature supports 57 languages +
+
+
+ + + +
+
+ +
+

+ Screenshots +

+
+
+
+
+

+ Setting API Key +

+

+ Simply set chatGPT API Key inside Settings. You can find your API key at + https://platform.openai.com/account/api-keys +

+ +
+
+

+ We can access ChatGPT from Text field section by typing '/'. +

+ +
+
+

+ When we're selecting the ChatGPT option, we can have an interface for entering the question and click Send Icon. +

+ +
+
+

+ We can see the generated response and also an 'INSERT' button. +

+ +
+
+

+ While clicking the 'INSERT' button the generated response from AI will be added to the Notes field. +

+ +
+
+

+ We can use the ChatGPT option for generating mail content also. +

+ +
+
+

+ Additional Feature +

+

+ Edit Content +

+

+ We can perform various process on the content + such as shortening , lengthening or rephrasing the content. + Access these features by selecting the content. +

+ +
+
+

+ Upon clicking the icon, a popup window emerges, presenting users + with various buttons for content processing options: shortening, + lengthening, or rephrasing. This interface allows users to select + their preferred method for modifying the content according to + their specific needs or objectives. +

+ +
+
+

+ By clicking any of the button it will generate response and shows + in the specified field, and we can replace the content by clicking + the 'REPLACE' button. +

+ +
+
+

+ If any errors while generating response it will return the response as error as shown in the image below. +

+ +
+
+

+ Generate Image +

+

+ Generate product image using AI while creating a new product or Updating name of a product. + To use the feature while creating a product, enable "Generate Image," enter a name for the product, and save. +

+ + +
+
+

+ For updating the product image while changing the product name, enable "Update Image". + By turning on it will automatically generate an image and update it. +

+ + +
+
+

+ If any errors encounter while generating or updating image using AI it will create a message in Log note. +

+ +
+
+

+ Speech-to-text +

+

+ Speech-to-Text using AI allows users to convert spoken language + into written text seamlessly. This feature leverages advanced artificial + intelligence to accurately transcribe voice inputs, enabling hands-free + interaction and improving efficiency in tasks such as note-taking, and content creation. +

+

+ We can access Speech-to-text from Text field section by typing '/'. +

+ +
+
+

+ When we're selecting the Speech-to-text option, we can have an interface for recoding audio. + Start the recording by clicking the button. +

+ +
+
+

+ After recording audio stop the recording by clicking the button. +

+ +
+
+

+ By stopping the recording, the system will process the audio and + provide the transcribed text in the response. +

+ +
+
+

+ While clicking the 'INSERT' button the generated Text form audio using AI will be added to the Notes field. +

+ + +
+
+
+ + + +
+
+ +
+

+ Related + Products +

+
+
+
+ +
+
+ + + +
+
+
+

Our Services

+
+
+ +
+
+ +
+
+ Odoo + Customization
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Support
+
+ + +
+
+ +
+
+ Hire + Odoo + Developer
+
+ +
+
+ +
+
+ Odoo + Integration
+
+ +
+
+ +
+
+ Odoo + Migration
+
+ + +
+
+ +
+
+ Odoo + Consultancy
+
+ +
+
+ +
+
+ Odoo Implementation
+
+ +
+
+ +
+
+ Odoo Licensing Consultancy
+
+
+
+ + + +
+
+
+

Our Industries

+
+
+ +
+
+ +
+ Trading +
+

+ Easily procure and sell your products

+
+
+ +
+
+ +
+ POS +
+

+ Easy + configuration + and convivial experience

+
+
+ +
+
+ +
+ Education +
+

+ A platform for + educational management

+
+
+ +
+
+ +
+ Manufacturing +
+

+ Plan, track and + schedule your operations

+
+
+ +
+
+ +
+ E-commerce & Website +
+

+ Mobile + friendly, + awe-inspiring product pages

+
+
+ +
+
+ +
+ Service Management +
+

+ Keep track of + services and invoice

+
+
+ +
+
+ +
+ Restaurant +
+

+ Run your bar or + restaurant methodically

+
+
+ +
+
+ +
+ Hotel Management +
+

+ An + all-inclusive + hotel management application

+
+
+ +
+
+ + + + + +
+
+
+

Need Help?

+
+
+
+ + +
+ +
+ + +
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+
+ \ No newline at end of file diff --git a/chatgpt_odoo_connector/static/src/Icons/icon.png b/chatgpt_odoo_connector/static/src/Icons/icon.png new file mode 100644 index 000000000..f8f653cdd Binary files /dev/null and b/chatgpt_odoo_connector/static/src/Icons/icon.png differ diff --git a/chatgpt_odoo_connector/static/src/css/chatgpt_odoo.css b/chatgpt_odoo_connector/static/src/css/chatgpt_odoo.css new file mode 100644 index 000000000..8a54f9352 --- /dev/null +++ b/chatgpt_odoo_connector/static/src/css/chatgpt_odoo.css @@ -0,0 +1,94 @@ +.popChatGPT{ + background-color: #2d2d2d; + width: 600px; + height: 360px; + position: fixed; + left: 28%; + top: 28%; + padding: 50px; + z-index: 9999; + border-radius: 25px; +} + +.popChatGPTAlter{ + background-color: #2d2d2d; + width: 600px; + height: 360px; + position: fixed; + left: 28%; + top: 28%; + padding: 50px; + z-index: 9999; + border-radius: 25px; +} + +.heading{ + color: white; + margin-left: 10px; +} + +.custom{ + width:48%; + border-radius:10px; +} + +.custom-input{ + padding: 0.375rem 0.75rem; + font-size: 1.08333333rem; + font-weight: 400; + line-height: 1.5; + color: #ffffff; + background-color: #353535; + background-clip: padding-box; + border: 1px solid #353535; + height:40px; + border-radius: 12px 0px 0px 12px; +} + +.custom-text{ + padding: 0.375rem 0.75rem; + font-size: 1.08333333rem; + font-weight: 400; + line-height: 1.5; + color: #ffffff; + background-color: #353535; + background-clip: padding-box; + border: 1px solid #353535; + resize:none; + border-radius: 12px; +} + +.alterButton{ + border-radius:10px; + width: 120px; +} + +#response::-webkit-scrollbar { + width: 5px; +} + +/* Track */ +#response::-webkit-scrollbar-track { + box-shadow: inset 0 0 5px grey; + border-radius: 10px; +} + +#response::-webkit-scrollbar-thumb { + background: white; + border-radius: 10px; +} + +#response::-webkit-scrollbar-thumb:hover { + background: #818281; +} + +.audio-record{ + display: flex; + justify-content: center +} + +.button-mic{ + border-radius: 13px; + height: 65px; + width: 55px; +} \ No newline at end of file diff --git a/chatgpt_odoo_connector/static/src/js/alternative_chatgpt.js b/chatgpt_odoo_connector/static/src/js/alternative_chatgpt.js new file mode 100644 index 000000000..85c30fedb --- /dev/null +++ b/chatgpt_odoo_connector/static/src/js/alternative_chatgpt.js @@ -0,0 +1,56 @@ +odoo.define('chatgpt_odoo_connector.alternative_chatgpt', function (require) { + 'use strict'; + var Widget = require('web.Widget'); + var rpc = require('web.rpc'); + /* Extending the widget */ + var AlternativeChatGPT = Widget.extend({ + template: 'alternativeChatGPT', + events: { + 'click .alterButton': '_onClick', + 'click .Replace': '_onClickReplace', + 'click .Cancel': '_onClickCancel', + }, + init: function(parent, options) { + this._super(parent); + $(document).on('click', this._onOutSideClick.bind(this)); + }, + start: function() { + var self = this; + this._super.apply(this, arguments); + }, + /* Function for clicking the buttons for shortening, lengthening and rephrasing the content */ + _onClick: function(event){ + var dataValue = event.target.getAttribute('data-value'); + var message = this.__parentedParent.__parentedParent.el.innerText + this.response = rpc.query({ + model: 'open.chatgpt', + method: 'edit_content', + args: [message,dataValue], + }).then((response) => { + document.getElementById('response').value = response; + }) + }, + /* Function for inserting the created response into the description field */ + _onClickReplace: function(){ + var new_content = document.getElementById('response').value; + if (new_content.trim()){ + this.__parentedParent.__parentedParent.el.innerText = new_content + this._onClickCancel(); + } + }, + /* Function for closing the widget while clicking outside */ + _onOutSideClick: function(ev){ + var element = document.querySelector('.popChatGPTAlter'); + var element_button = document.getElementsByClassName('chatgpt'); + var isClickInsideElementButton = Array.from(element_button).some(button => button.contains(ev.target)); + if (element && !element.contains(ev.target) && !isClickInsideElementButton){ + this._onClickCancel(); + } + }, + /* Function for closing */ + _onClickCancel: function(){ + this.destroy() + } + }); + return AlternativeChatGPT; +}); diff --git a/chatgpt_odoo_connector/static/src/js/custom_toolbar.js b/chatgpt_odoo_connector/static/src/js/custom_toolbar.js new file mode 100644 index 000000000..032b7169f --- /dev/null +++ b/chatgpt_odoo_connector/static/src/js/custom_toolbar.js @@ -0,0 +1,21 @@ +odoo.define('chatgpt_odoo_connector.custom_toolbar', function (require) { + 'use strict'; + var web_editor = require('web_editor.toolbar'); + var Dialog = require('web.Dialog'); + var AlternativeChatGPT = require('chatgpt_odoo_connector.alternative_chatgpt'); + /* Adding a new button to the toolbar */ + var toolbar = web_editor.include({ + start: function () { + var res = this._super.apply(this, arguments); + this.$el.on('click', '#open-chatgpt', this._onButtonClick.bind(this)); + return res; + }, + /* Function for showing the widget while clicking the button. */ + _onButtonClick: function () { + if (!this.alternativeChatGPT || this.alternativeChatGPT.isDestroyed()) { + this.alternativeChatGPT = new AlternativeChatGPT(this); + } + this.alternativeChatGPT.appendTo(this.el.offsetParent); + }, + }); +}); diff --git a/chatgpt_odoo_connector/static/src/js/open_chatgpt.js b/chatgpt_odoo_connector/static/src/js/open_chatgpt.js new file mode 100644 index 000000000..d5c455d08 --- /dev/null +++ b/chatgpt_odoo_connector/static/src/js/open_chatgpt.js @@ -0,0 +1,93 @@ +/** @odoo-module **/ +const { Component, useState, useExternalListener, xml } = owl; +import { registry } from "@web/core/registry"; +/* Extending the component and creating class OpenChatGPT */ +export class OpenChatGPT extends Component { + constructor() { + super(...arguments); + this.state = useState({ + message: '', + response: '' + }); + this.Send = this.Send.bind(this); + this.Cancel = this.Cancel.bind(this); + this.onWindowEnter = this.onWindowEnter.bind(this); + useExternalListener(window, "click", this.onWindowClick); + useExternalListener(window, "keydown", this.onWindowEnter); + } + /* Getting the response based on the message provided */ + async Send(ev){ + if (ev.state.message.trim()){ + this.state.response = await this.props.rpc.query({ + model: 'open.chatgpt', + method: 'get_response', + args: [ev.state.message], + }) + } + } + + /* Function for inserting the response to the description field */ + insert(){ + var content = this.state.response + const lines = content.split('\n').filter(line => line.trim().length); + const fragment = document.createDocumentFragment(); + for (const line of lines) { + const block = document.createElement(line.startsWith('Title: ') ? 'h2' : 'p'); + block.innerText = line; + fragment.appendChild(block); + } + this.props.self.el.appendChild(fragment); + this.Cancel() + } + + /* Function for cancelling */ + Cancel(){ + var element = document.querySelector('.popChatGPT'); + element.remove(); + } + + /* Function for closing the widget while clicking outside */ + onWindowClick(ev) { + var element = document.querySelector('.popChatGPT'); + if (element && !element.contains(ev.target)){ + element.remove(); + } + } + /* Function for calling the function Send */ + onWindowEnter(ev){ + var element = document.querySelector('.popChatGPT'); + if (element && ev.key == 'Enter'){ + this.Send(this) + } + } +} + +OpenChatGPT.template = xml` +
+
+ +
ChatGPT
+
+
+
+ +
+ + +
+
+ +
+
+ +
+
+
+ + +
+
`; +registry.category("actions").add("chatGPT", OpenChatGPT); diff --git a/chatgpt_odoo_connector/static/src/js/recordAudio.js b/chatgpt_odoo_connector/static/src/js/recordAudio.js new file mode 100644 index 000000000..074f84e33 --- /dev/null +++ b/chatgpt_odoo_connector/static/src/js/recordAudio.js @@ -0,0 +1,128 @@ +/** @odoo-module **/ +const { Component, useState, useRef, useExternalListener, xml } = owl; +import { registry } from "@web/core/registry"; +import { browser } from '@web/core/browser/browser'; +import {_t} from 'web.core'; +/* Extending the component and creating class recordAudio */ +export class recordAudio extends Component { + constructor() { + super(...arguments); + this.state = useState({ + startedRecording: '', + transcriptedText: '', + audioChunks: [], + }); + this.recordAudio = this.recordAudio.bind(this); + this.stopRecord = this.stopRecord.bind(this); + this.onWindowClick = this.onWindowClick.bind(this); + useExternalListener(window, "click", this.onWindowClick); + } + /* Function for recording audio and save the recording in a file. */ + async recordAudio(ev){ + this.state.startedRecording = true + this.state.audioChunks = []; + try { + const stream = await navigator.mediaDevices.getUserMedia({ audio: true }); + this.mediaRecorder = new MediaRecorder(stream); + this.mediaRecorder.ondataavailable = (e) => { + if (e.data.size > 0) { + this.state.audioChunks.push(e.data); + } + }; + + this.mediaRecorder.onstop = async () => { + if (this.state.audioChunks.length > 0) { + const audioBlob = new Blob(this.state.audioChunks, { type: 'audio/wav' }); + const file = new File([audioBlob], 'recorded_audio.wav', { type: 'audio/wav' }); + const formData = new FormData(); + formData.append('file', file); + const response = await fetch('/upload_audio', { + method: 'POST', + body: formData, + }); + const { filePath } = await response.json(); + this.state.transcriptedText = await this.props.rpc.query({ + model: 'open.chatgpt', + method: 'convert_to_text', + args: [filePath], + }) + } + }; + + this.audioStream = stream; + this.mediaRecorder.start(); + } catch (error) { + this.props.self.displayNotification({ + title: _t('Warning'), + message: "Recording Error: Error accessing Microphone" + }); + } + } + /* Function for stop audio recording */ + async stopRecord() { + this.state.startedRecording = false; + if (this.mediaRecorder && this.mediaRecorder.state !== 'inactive') { + this.mediaRecorder.stop(); + if (this.audioStream) { + this.audioStream.getTracks().forEach(track => track.stop()); + } + } + } + + /* Function for inserting the converted text from the audio file. */ + Insert(){ + var content = this.state.transcriptedText + const lines = content.split('\n').filter(line => line.trim().length); + const fragment = document.createDocumentFragment(); + for (const line of lines) { + const block = document.createElement(line.startsWith('Title: ') ? 'h2' : 'p'); + block.innerText = line; + fragment.appendChild(block); + } + this.props.self.el.appendChild(fragment); + this.Cancel() + } + + /* Function for cancelling it will remove the element popChatGPT*/ + Cancel(){ + var element = document.querySelector('.popChatGPT'); + element.remove(); + } + /* Function for closing the widget while clicking outside */ + onWindowClick(ev) { + var element = document.querySelector('.popChatGPT'); + if (element && !element.contains(ev.target)){ + this.Cancel() + } + } + +} + +recordAudio.template = xml` +
+
+ +
Speech-to-text
+
+
+
+ + +
+ +
+
+ +
+
+
+ + +
+
`; +registry.category("actions").add("recordAudio", recordAudio); diff --git a/chatgpt_odoo_connector/static/src/js/wysiwyg.js b/chatgpt_odoo_connector/static/src/js/wysiwyg.js new file mode 100644 index 000000000..aa40d9010 --- /dev/null +++ b/chatgpt_odoo_connector/static/src/js/wysiwyg.js @@ -0,0 +1,62 @@ +/** @odoo-module **/ +import Wysiwyg from 'web_editor.wysiwyg'; +import { browser } from '@web/core/browser/browser'; +import { _t } from 'web.core'; +var Dialog = require('web.Dialog'); +var core = require('web.core'); +var QWeb = core.qweb; +var rpc = require('web.rpc'); +import { OpenChatGPT } from "./open_chatgpt"; +import { recordAudio } from "./recordAudio"; +const { mount } = owl; +/* Appending new Category AI Tools, Chatgpt tool, and Speech-to-text tool in the powerbox options */ +Wysiwyg.include({ + init: function (parent, options) { + this._super.apply(this, arguments); + }, + /* Function for adding new category and tool */ + _getPowerboxOptions: function (){ + const options = this._super(); + const { commands, categories } = options; + const Category = { + name: _t('AI Tools'), + priority: 40 + }; + const itemSectionCommand = { + category: _t('AI Tools'), + name: _t('ChatGPT'), + priority: 40, + description: _t('Generate content with AI'), + fontawesome: 'fa-magic', + callback: this._openChatGPT.bind(this) + }; + const itemSpeechToAudio = { + category: _t('AI Tools'), + name: _t('Speech-To-Text'), + priority: 40, + description: _t('Speech to text'), + fontawesome: 'fa-microphone', + callback: this._recordVoice.bind(this) + }; + categories.push(Category); + commands.push(itemSectionCommand); + commands.push(itemSpeechToAudio); + return options; + }, + /* Function for mounting the element of chatgpt in the view */ + _openChatGPT: function () { + var element = $('.o_web_client')[0]; + if (element) { + const props = {rpc: rpc, self: this}; + mount(OpenChatGPT, element, {props: props}); + } + }, + /* Function for mounting the element speech-to-text in the view */ + _recordVoice: function () { + var element = $('.o_web_client')[0]; + if (element) { + const props = {rpc: rpc, self: this}; + mount(recordAudio, element, {props: props}); + } + }, +}); diff --git a/chatgpt_odoo_connector/static/src/xml/alternative_chatgpt.xml b/chatgpt_odoo_connector/static/src/xml/alternative_chatgpt.xml new file mode 100644 index 000000000..f46b3063c --- /dev/null +++ b/chatgpt_odoo_connector/static/src/xml/alternative_chatgpt.xml @@ -0,0 +1,33 @@ + + + + +
+
+ +
ChatGPT
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+
+ +