diff --git a/onedrive_integration_odoo/README.rst b/onedrive_integration_odoo/README.rst new file mode 100644 index 000000000..ca2bd989b --- /dev/null +++ b/onedrive_integration_odoo/README.rst @@ -0,0 +1,54 @@ +.. 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 + +Onedrive Integration +==================== +Onedrive Integration provides seamless integration with OneDrive, allowing users +to conveniently access their uploaded files from within the Odoo platform. With +this integration, users can easily view, upload and download files stored in +their OneDrive accounts, all from within their Odoo environment. + +Configuration +============= +The user should create onedrive client id, client secret from microsoft azure +with scope 'offline_access, openid, Files.ReadWrite.All' to get access token. +Folder id is the id on onedrive folder url + +License +------- +General Public License, Version 3 (AGPL v3). +(http://www.gnu.org/licenses/agpl-3.0-standalone.html) + +Company +------- +* `Cybrosys Techno Solutions `__ + +Credits +------- +* Developer: + (V16) Aslam A K, + (V17) Jumana Haseen, +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 https://www.cybrosys.com + +Further information +=================== +HTML Description: ``__ diff --git a/onedrive_integration_odoo/__init__.py b/onedrive_integration_odoo/__init__.py new file mode 100644 index 000000000..d4164f8b8 --- /dev/null +++ b/onedrive_integration_odoo/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Jumana Haseen ( odoo@cybrosys.com ) +# +# 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 +from . import wizard +from .hooks import uninstall_hook diff --git a/onedrive_integration_odoo/__manifest__.py b/onedrive_integration_odoo/__manifest__.py new file mode 100644 index 000000000..bd05aa047 --- /dev/null +++ b/onedrive_integration_odoo/__manifest__.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Jumana Haseen ( odoo@cybrosys.com ) +# +# 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': "Onedrive Integration", + 'version': "17.0.1.0.0", + 'category': "Productivity", + 'summary': """Upload and download files in Onedrive using odoo """, + 'description': """This module was developed to upload files to Onedrive as + well as access files from Onedrive in Odoo.""", + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': "https://www.cybrosys.com", + 'depends': ['base_setup'], + 'data': [ + 'security/ir.model.access.csv', + 'wizard/upload_file_views.xml', + 'views/onedrive_dashboard_views.xml', + 'views/res_config_settings_views.xml', + ], + 'assets': { + 'web.assets_backend': [ + '/onedrive_integration_odoo/static/src/js/onedrive.js', + '/onedrive_integration_odoo/static/src/scss/onedrive.scss', + '/onedrive_integration_odoo/static/src/xml/onedrive_dashboard.xml' + ], + }, + 'images': ['static/description/banner.png'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': True, + 'uninstall_hook': 'uninstall_hook', +} diff --git a/onedrive_integration_odoo/controllers/__init__.py b/onedrive_integration_odoo/controllers/__init__.py new file mode 100644 index 000000000..e78574081 --- /dev/null +++ b/onedrive_integration_odoo/controllers/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Jumana Haseen ( odoo@cybrosys.com ) +# +# 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 onedrive_integration_odoo diff --git a/onedrive_integration_odoo/controllers/onedrive_integration_odoo.py b/onedrive_integration_odoo/controllers/onedrive_integration_odoo.py new file mode 100644 index 000000000..4a963f7a4 --- /dev/null +++ b/onedrive_integration_odoo/controllers/onedrive_integration_odoo.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Jumana Haseen ( odoo@cybrosys.com ) +# +# 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 json +from odoo import http +from odoo.http import request + + +class OnedriveAuth(http.Controller): + """ + Return URL + """ + + @http.route('/onedrive/authentication', type='http', auth="public") + def oauth2callback(self, **kw): + """ + This is a controller that defines a route for handling HTTP requests + . In this case, it's defining a route at the URL path + '/onedrive/authentication'. The route is accessible via HTTP, and the + authentication method used is set to "public. + """ + state = json.loads(kw['state']) + onedrive_config_id = request.env['onedrive.dashboard'].sudo().browse( + state.get('onedrive_config_id')) + onedrive_config_id.get_tokens(kw.get('code')) + return request.redirect(state.get('url_return')) diff --git a/onedrive_integration_odoo/doc/RELEASE_NOTES.md b/onedrive_integration_odoo/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..09b00287e --- /dev/null +++ b/onedrive_integration_odoo/doc/RELEASE_NOTES.md @@ -0,0 +1,5 @@ +## Module +#### 24.01.2024 +#### Version 17.0.1.0.0 +#### ADD +- Initial commit for Onedrive Integration diff --git a/onedrive_integration_odoo/hooks.py b/onedrive_integration_odoo/hooks.py new file mode 100644 index 000000000..ce42dda04 --- /dev/null +++ b/onedrive_integration_odoo/hooks.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Jumana Haseen ( odoo@cybrosys.com ) +# +# 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 SUPERUSER_ID, api + + +def uninstall_hook(cr, registry): + """ + Delete System Parameters + """ + env = api.Environment(cr, SUPERUSER_ID, {}) + env['ir.config_parameter'].sudo().search( + [('key', '=', 'onedrive_integration_odoo.client_id')]).unlink() + env['ir.config_parameter'].sudo().search( + [('key', '=', 'onedrive_integration_odoo.client_secret')]).unlink() + env['ir.config_parameter'].sudo().search( + [('key', '=', 'onedrive_integration_odoo.folder_id')]).unlink() + env['ir.config_parameter'].sudo().search( + [('key', '=', 'onedrive_integration_odoo.onedrive_button')]).unlink() diff --git a/onedrive_integration_odoo/models/__init__.py b/onedrive_integration_odoo/models/__init__.py new file mode 100644 index 000000000..ab54e96a7 --- /dev/null +++ b/onedrive_integration_odoo/models/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Jumana Haseen ( odoo@cybrosys.com ) +# +# 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 onedrive_dashboard +from . import res_config_settings diff --git a/onedrive_integration_odoo/models/onedrive_dashboard.py b/onedrive_integration_odoo/models/onedrive_dashboard.py new file mode 100644 index 000000000..6bf3e69d4 --- /dev/null +++ b/onedrive_integration_odoo/models/onedrive_dashboard.py @@ -0,0 +1,150 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Jumana Haseen ( odoo@cybrosys.com ) +# +# 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 json +import logging +import requests +from datetime import timedelta +from odoo import fields, models +from odoo.http import request + +_logger = logging.getLogger(__name__) + + +class OneDriveDashboard(models.Model): + """ + Generate refresh and access token + """ + _name = 'onedrive.dashboard' + _description = "Generate access and refresh tokens " + + onedrive_access_token = fields.Char( + string="OneDrive Access Token", + store=True, + help="Access token for authenticating and accessing OneDrive APIs.") + onedrive_refresh_token = fields.Char( + string="OneDrive Refresh Token", + help="Refresh token for obtaining a new access token when the current " + "one expires.") + token_expiry_date = fields.Char( + string="OneDrive Token Validity", + help="Validity period of the access token, indicating until when it is" + " valid.") + upload_file = fields.Binary( + string="Upload File", + help="Binary field to store the uploaded file.") + + def get_tokens(self, authorize_code): + """ + Generate onedrive tokens from authorization code + """ + data = { + 'code': authorize_code, + 'client_id': self.env['ir.config_parameter'].get_param( + 'onedrive_integration_odoo.client_id', ''), + 'client_secret': self.env['ir.config_parameter'].get_param( + 'onedrive_integration_odoo.client_secret', ''), + 'grant_type': 'authorization_code', + 'scope': ['offline_access openid Files.ReadWrite.All'], + 'redirect_uri': request.env['ir.config_parameter'].get_param( + 'web.base.url') + '/onedrive/authentication' + } + try: + res = requests.post( + "https://login.microsoftonline.com/common/oauth2/v2.0/token", + data=data, + headers={"content-type": "application/x-www-form-urlencoded"}) + res.raise_for_status() + response = res.content and res.json() or {} + if response: + expires_in = response.get('expires_in') + self.env['onedrive.dashboard'].create({ + 'onedrive_access_token': response.get('access_token'), + 'onedrive_refresh_token': response.get('refresh_token'), + 'token_expiry_date': fields.Datetime.now() + timedelta( + seconds=expires_in) if expires_in else False, + }) + except requests.HTTPError as error: + _logger.exception("Bad microsoft onedrive request : %s !", + error.response.content) + raise error + + def generate_onedrive_refresh_token(self): + """ + Generate onedrive access token from refresh token if expired + """ + data = { + 'client_id': self.env['ir.config_parameter'].get_param( + 'onedrive_integration_odoo.client_id', ''), + 'client_secret': self.env['ir.config_parameter'].get_param( + 'onedrive_integration_odoo.client_secret', ''), + 'scope': ['offline_access openid Files.ReadWrite.All'], + 'grant_type': "refresh_token", + 'redirect_uri': request.env['ir.config_parameter'].get_param( + 'web.base.url') + '/onedrive/authentication', + 'refresh_token': self.onedrive_refresh_token + } + try: + res = requests.post( + "https://login.microsoftonline.com/common/oauth2/v2.0/token", + data=data, + headers={"Content-type": "application/x-www-form-urlencoded"}) + res.raise_for_status() + response = res.content and res.json() or {} + if response: + expires_in = response.get('expires_in') + self.write({ + 'onedrive_access_token': response.get('access_token'), + 'onedrive_refresh_token': response.get('refresh_token'), + 'token_expiry_date': fields.Datetime.now() + timedelta( + seconds=expires_in) if expires_in else False, + }) + except requests.HTTPError as error: + _logger.exception("Bad microsoft onedrive request : %s !", + error.response.content) + raise error + + def action_synchronize_onedrive(self): + """ + Pass the files to javascript + """ + record = self.search([], order='id desc', limit=1) + if not record: + return False + if record.token_expiry_date <= str(fields.Datetime.now()): + record.generate_onedrive_refresh_token() + folder = self.env['ir.config_parameter'].get_param( + 'onedrive_integration_odoo.folder_id', '') + if not folder:return False + url = "https://graph.microsoft.com/v1.0/me/drive/items/%s/children" \ + "?Content-Type=application/json" % folder + response = requests.request("GET", url, headers={ + 'Authorization': 'Bearer "' + record.onedrive_access_token + '"'}, + data={}) + message = json.loads(response.content) + if 'error' in message: + return ['error', message['error']['code'], + message['error']['message']] + files = {} + for file in response.json().get('value'): + if list(file.keys())[0] == '@microsoft.graph.downloadUrl': + files[file['name']] = file['@microsoft.graph.downloadUrl'] + return files diff --git a/onedrive_integration_odoo/models/res_config_settings.py b/onedrive_integration_odoo/models/res_config_settings.py new file mode 100644 index 000000000..89eb67eb5 --- /dev/null +++ b/onedrive_integration_odoo/models/res_config_settings.py @@ -0,0 +1,108 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Jumana Haseen ( odoo@cybrosys.com ) +# +# 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 json +import requests +from werkzeug import urls +from odoo import fields, models, _ +from odoo.exceptions import UserError +from odoo.http import request + + +class ResConfigSettings(models.TransientModel): + """ + This model represents the configuration settings for the OneDrive + integration in Odoo.It allows users to configure various parameters for + OneDrive integration, including client ID, client secret, access token, + and folder ID. + """ + _inherit = 'res.config.settings' + + onedrive_client = fields.Char( + string='Onedrive Client ID', copy=False, + config_parameter='onedrive_integration_odoo.client_id', + help="Client ID for accessing OneDrive API") + onedrive_client_secret = fields.Char( + string='Onedrive Client Secret', + config_parameter='onedrive_integration_odoo.client_secret', + help="Client Secret for accessing OneDrive API") + onedrive_access_token = fields.Char( + string='Onedrive Access Token', + help="Access Token for authenticating with OneDrive API") + onedrive_refresh_token = fields.Char( + string='Onedrive Refresh Token', + help="Refresh Token for refreshing the access token") + onedrive_folder = fields.Char( + string='Folder ID', help="ID of the folder in OneDrive", + config_parameter='onedrive_integration_odoo.folder_id') + is_onedrive_enabled = fields.Boolean( + string="Synchronize Onedrive with odoo", + config_parameter='onedrive_integration_odoo.onedrive_button', + help="Enable/Disable OneDrive integration") + + def action_get_onedrive_auth_code(self): + """ + Generate onedrive authorization code + """ + data = { + 'client_id': self.env['ir.config_parameter'].get_param( + 'onedrive_integration_odoo.client_id', ''), + 'client_secret': self.env['ir.config_parameter'].get_param( + 'onedrive_integration_odoo.client_secret', ''), + 'grant_type': 'client_credentials', + 'scope': "https://graph.microsoft.com/.default", + 'redirect_uri': request.env['ir.config_parameter'].get_param( + 'web.base.url') + '/onedrive/authentication' + } + res = requests.post( + "https://login.microsoftonline.com/common/oauth2/v2.0/token", + data=data, + headers={"content-type": "application/x-www-form-urlencoded"}) + response = res.content and res.json() or {} + if 'error' in response: + raise UserError(_("Error '%s': Please check the credentials.", + response['error'])) + else: + authority = 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize' + action = self.env["ir.actions.client"].sudo()._for_xml_id( + "onedrive_integration_odoo.onedrive_dashboard_action") + base_url = request.env['ir.config_parameter'].get_param( + 'web.base.url') + url_return = base_url + '/web#id=%d&action=%d&view_type=form&model=%s' \ + % (self.id, action['id'], 'onedrive.dashboard') + encoded_params = urls.url_encode({ + 'response_type': 'code', + 'client_id': self.env['ir.config_parameter'].get_param( + 'onedrive_integration_odoo.client_id', ''), + 'state': json.dumps({ + 'onedrive_config_id': self.id, + 'url_return': url_return + }), + 'scope': ['offline_access openid Files.ReadWrite.All'], + 'redirect_uri': base_url + '/onedrive/authentication', + 'prompt': 'consent', + 'access_type': 'offline' + }) + return { + 'type': 'ir.actions.act_url', + 'target': 'self', + 'url': "%s?%s" % (authority, encoded_params), + } diff --git a/onedrive_integration_odoo/security/ir.model.access.csv b/onedrive_integration_odoo/security/ir.model.access.csv new file mode 100644 index 000000000..39220b27e --- /dev/null +++ b/onedrive_integration_odoo/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink +access_onedrive_dashboard_user,access.onedrive.dashboard.user,model_onedrive_dashboard,base.group_user,1,1,1,1 +access_upload_file_user,access.upload.file.user,model_upload_file,base.group_user,1,1,1,1 diff --git a/onedrive_integration_odoo/static/description/assets/icons/capture (1).png b/onedrive_integration_odoo/static/description/assets/icons/capture (1).png new file mode 100644 index 000000000..8824deafc Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/icons/capture (1).png differ diff --git a/onedrive_integration_odoo/static/description/assets/icons/check.png b/onedrive_integration_odoo/static/description/assets/icons/check.png new file mode 100644 index 000000000..c8e85f51d Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/icons/check.png differ diff --git a/onedrive_integration_odoo/static/description/assets/icons/chevron.png b/onedrive_integration_odoo/static/description/assets/icons/chevron.png new file mode 100644 index 000000000..2089293d6 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/icons/chevron.png differ diff --git a/onedrive_integration_odoo/static/description/assets/icons/cogs.png b/onedrive_integration_odoo/static/description/assets/icons/cogs.png new file mode 100644 index 000000000..95d0bad62 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/icons/cogs.png differ diff --git a/onedrive_integration_odoo/static/description/assets/icons/consultation.png b/onedrive_integration_odoo/static/description/assets/icons/consultation.png new file mode 100644 index 000000000..8319d4baa Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/icons/consultation.png differ diff --git a/onedrive_integration_odoo/static/description/assets/icons/ecom-black.png b/onedrive_integration_odoo/static/description/assets/icons/ecom-black.png new file mode 100644 index 000000000..a9385ff13 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/icons/ecom-black.png differ diff --git a/onedrive_integration_odoo/static/description/assets/icons/education-black.png b/onedrive_integration_odoo/static/description/assets/icons/education-black.png new file mode 100644 index 000000000..3eb09b27b Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/icons/education-black.png differ diff --git a/onedrive_integration_odoo/static/description/assets/icons/hotel-black.png b/onedrive_integration_odoo/static/description/assets/icons/hotel-black.png new file mode 100644 index 000000000..130f613be Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/icons/hotel-black.png differ diff --git a/onedrive_integration_odoo/static/description/assets/icons/img.png b/onedrive_integration_odoo/static/description/assets/icons/img.png new file mode 100644 index 000000000..70197f477 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/icons/img.png differ diff --git a/onedrive_integration_odoo/static/description/assets/icons/license.png b/onedrive_integration_odoo/static/description/assets/icons/license.png new file mode 100644 index 000000000..a5869797e Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/icons/license.png differ diff --git a/onedrive_integration_odoo/static/description/assets/icons/lifebuoy.png b/onedrive_integration_odoo/static/description/assets/icons/lifebuoy.png new file mode 100644 index 000000000..658d56ccc Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/icons/lifebuoy.png differ diff --git a/onedrive_integration_odoo/static/description/assets/icons/manufacturing-black.png b/onedrive_integration_odoo/static/description/assets/icons/manufacturing-black.png new file mode 100644 index 000000000..697eb0e9f Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/icons/manufacturing-black.png differ diff --git a/onedrive_integration_odoo/static/description/assets/icons/photo-capture.png b/onedrive_integration_odoo/static/description/assets/icons/photo-capture.png new file mode 100644 index 000000000..06c111758 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/icons/photo-capture.png differ diff --git a/onedrive_integration_odoo/static/description/assets/icons/pos-black.png b/onedrive_integration_odoo/static/description/assets/icons/pos-black.png new file mode 100644 index 000000000..97c0f90c1 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/icons/pos-black.png differ diff --git a/onedrive_integration_odoo/static/description/assets/icons/puzzle.png b/onedrive_integration_odoo/static/description/assets/icons/puzzle.png new file mode 100644 index 000000000..65cf854e7 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/icons/puzzle.png differ diff --git a/onedrive_integration_odoo/static/description/assets/icons/restaurant-black.png b/onedrive_integration_odoo/static/description/assets/icons/restaurant-black.png new file mode 100644 index 000000000..4a35eb939 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/icons/restaurant-black.png differ diff --git a/onedrive_integration_odoo/static/description/assets/icons/service-black.png b/onedrive_integration_odoo/static/description/assets/icons/service-black.png new file mode 100644 index 000000000..301ab51cb Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/icons/service-black.png differ diff --git a/onedrive_integration_odoo/static/description/assets/icons/trading-black.png b/onedrive_integration_odoo/static/description/assets/icons/trading-black.png new file mode 100644 index 000000000..9398ba2f1 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/icons/trading-black.png differ diff --git a/onedrive_integration_odoo/static/description/assets/icons/training.png b/onedrive_integration_odoo/static/description/assets/icons/training.png new file mode 100644 index 000000000..884ca024d Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/icons/training.png differ diff --git a/onedrive_integration_odoo/static/description/assets/icons/update.png b/onedrive_integration_odoo/static/description/assets/icons/update.png new file mode 100644 index 000000000..ecbc5a01a Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/icons/update.png differ diff --git a/onedrive_integration_odoo/static/description/assets/icons/user.png b/onedrive_integration_odoo/static/description/assets/icons/user.png new file mode 100644 index 000000000..6ffb23d9f Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/icons/user.png differ diff --git a/onedrive_integration_odoo/static/description/assets/icons/wrench.png b/onedrive_integration_odoo/static/description/assets/icons/wrench.png new file mode 100644 index 000000000..6c04dea0f Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/icons/wrench.png differ diff --git a/onedrive_integration_odoo/static/description/assets/misc/Cybrosys R.png b/onedrive_integration_odoo/static/description/assets/misc/Cybrosys R.png new file mode 100644 index 000000000..da4058087 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/misc/Cybrosys R.png differ diff --git a/onedrive_integration_odoo/static/description/assets/misc/email.svg b/onedrive_integration_odoo/static/description/assets/misc/email.svg new file mode 100644 index 000000000..15291cdc3 --- /dev/null +++ b/onedrive_integration_odoo/static/description/assets/misc/email.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/onedrive_integration_odoo/static/description/assets/misc/phone.svg b/onedrive_integration_odoo/static/description/assets/misc/phone.svg new file mode 100644 index 000000000..b7bd7f251 --- /dev/null +++ b/onedrive_integration_odoo/static/description/assets/misc/phone.svg @@ -0,0 +1,3 @@ + + + diff --git a/onedrive_integration_odoo/static/description/assets/misc/star (1) 2.svg b/onedrive_integration_odoo/static/description/assets/misc/star (1) 2.svg new file mode 100644 index 000000000..5ae9f507a --- /dev/null +++ b/onedrive_integration_odoo/static/description/assets/misc/star (1) 2.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/onedrive_integration_odoo/static/description/assets/misc/support (1) 1.svg b/onedrive_integration_odoo/static/description/assets/misc/support (1) 1.svg new file mode 100644 index 000000000..7d37a8f30 --- /dev/null +++ b/onedrive_integration_odoo/static/description/assets/misc/support (1) 1.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/onedrive_integration_odoo/static/description/assets/misc/support-email.svg b/onedrive_integration_odoo/static/description/assets/misc/support-email.svg new file mode 100644 index 000000000..eb70370d6 --- /dev/null +++ b/onedrive_integration_odoo/static/description/assets/misc/support-email.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/onedrive_integration_odoo/static/description/assets/misc/tick-mark.svg b/onedrive_integration_odoo/static/description/assets/misc/tick-mark.svg new file mode 100644 index 000000000..2dbb40187 --- /dev/null +++ b/onedrive_integration_odoo/static/description/assets/misc/tick-mark.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/onedrive_integration_odoo/static/description/assets/misc/whatsapp 1.svg b/onedrive_integration_odoo/static/description/assets/misc/whatsapp 1.svg new file mode 100644 index 000000000..0bfaf8fc6 --- /dev/null +++ b/onedrive_integration_odoo/static/description/assets/misc/whatsapp 1.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/onedrive_integration_odoo/static/description/assets/misc/whatsapp.svg b/onedrive_integration_odoo/static/description/assets/misc/whatsapp.svg new file mode 100644 index 000000000..b618aea1d --- /dev/null +++ b/onedrive_integration_odoo/static/description/assets/misc/whatsapp.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/onedrive_integration_odoo/static/description/assets/modules/1.png b/onedrive_integration_odoo/static/description/assets/modules/1.png new file mode 100644 index 000000000..f7c7f6aff Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/modules/1.png differ diff --git a/onedrive_integration_odoo/static/description/assets/modules/2.png b/onedrive_integration_odoo/static/description/assets/modules/2.png new file mode 100644 index 000000000..b3355799d Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/modules/2.png differ diff --git a/onedrive_integration_odoo/static/description/assets/modules/3.png b/onedrive_integration_odoo/static/description/assets/modules/3.png new file mode 100644 index 000000000..3a640d24b Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/modules/3.png differ diff --git a/onedrive_integration_odoo/static/description/assets/modules/4.png b/onedrive_integration_odoo/static/description/assets/modules/4.png new file mode 100644 index 000000000..38374d01c Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/modules/4.png differ diff --git a/onedrive_integration_odoo/static/description/assets/modules/5.png b/onedrive_integration_odoo/static/description/assets/modules/5.png new file mode 100644 index 000000000..9f8fb6f71 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/modules/5.png differ diff --git a/onedrive_integration_odoo/static/description/assets/modules/6.png b/onedrive_integration_odoo/static/description/assets/modules/6.png new file mode 100644 index 000000000..15e182f3c Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/modules/6.png differ diff --git a/onedrive_integration_odoo/static/description/assets/screenshots/hero.gif b/onedrive_integration_odoo/static/description/assets/screenshots/hero.gif new file mode 100644 index 000000000..6b6ef5096 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/hero.gif differ diff --git a/onedrive_integration_odoo/static/description/assets/screenshots/mic1.png b/onedrive_integration_odoo/static/description/assets/screenshots/mic1.png new file mode 100644 index 000000000..be8f33504 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/mic1.png differ diff --git a/onedrive_integration_odoo/static/description/assets/screenshots/mic10.png b/onedrive_integration_odoo/static/description/assets/screenshots/mic10.png new file mode 100644 index 000000000..c7ba69dc4 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/mic10.png differ diff --git a/onedrive_integration_odoo/static/description/assets/screenshots/mic11.png b/onedrive_integration_odoo/static/description/assets/screenshots/mic11.png new file mode 100644 index 000000000..cf80210f9 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/mic11.png differ diff --git a/onedrive_integration_odoo/static/description/assets/screenshots/mic12.png b/onedrive_integration_odoo/static/description/assets/screenshots/mic12.png new file mode 100644 index 000000000..d8801ffac Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/mic12.png differ diff --git a/onedrive_integration_odoo/static/description/assets/screenshots/mic13.png b/onedrive_integration_odoo/static/description/assets/screenshots/mic13.png new file mode 100644 index 000000000..1f55dfc9d Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/mic13.png differ diff --git a/onedrive_integration_odoo/static/description/assets/screenshots/mic14.png b/onedrive_integration_odoo/static/description/assets/screenshots/mic14.png new file mode 100644 index 000000000..f7cbe0391 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/mic14.png differ diff --git a/onedrive_integration_odoo/static/description/assets/screenshots/mic15.png b/onedrive_integration_odoo/static/description/assets/screenshots/mic15.png new file mode 100644 index 000000000..031914dec Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/mic15.png differ diff --git a/onedrive_integration_odoo/static/description/assets/screenshots/mic2.png b/onedrive_integration_odoo/static/description/assets/screenshots/mic2.png new file mode 100644 index 000000000..cc5d566c9 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/mic2.png differ diff --git a/onedrive_integration_odoo/static/description/assets/screenshots/mic3.png b/onedrive_integration_odoo/static/description/assets/screenshots/mic3.png new file mode 100644 index 000000000..d98d856fd Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/mic3.png differ diff --git a/onedrive_integration_odoo/static/description/assets/screenshots/mic4.png b/onedrive_integration_odoo/static/description/assets/screenshots/mic4.png new file mode 100644 index 000000000..579415fc4 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/mic4.png differ diff --git a/onedrive_integration_odoo/static/description/assets/screenshots/mic5.png b/onedrive_integration_odoo/static/description/assets/screenshots/mic5.png new file mode 100644 index 000000000..f134f35d9 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/mic5.png differ diff --git a/onedrive_integration_odoo/static/description/assets/screenshots/mic6.png b/onedrive_integration_odoo/static/description/assets/screenshots/mic6.png new file mode 100644 index 000000000..d38849e51 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/mic6.png differ diff --git a/onedrive_integration_odoo/static/description/assets/screenshots/mic7.png b/onedrive_integration_odoo/static/description/assets/screenshots/mic7.png new file mode 100644 index 000000000..6db8280b4 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/mic7.png differ diff --git a/onedrive_integration_odoo/static/description/assets/screenshots/mic8.png b/onedrive_integration_odoo/static/description/assets/screenshots/mic8.png new file mode 100644 index 000000000..6aaac571d Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/mic8.png differ diff --git a/onedrive_integration_odoo/static/description/assets/screenshots/mic9.png b/onedrive_integration_odoo/static/description/assets/screenshots/mic9.png new file mode 100644 index 000000000..f51aa6d56 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/mic9.png differ diff --git a/onedrive_integration_odoo/static/description/banner.png b/onedrive_integration_odoo/static/description/banner.png new file mode 100644 index 000000000..f66f38851 Binary files /dev/null and b/onedrive_integration_odoo/static/description/banner.png differ diff --git a/onedrive_integration_odoo/static/description/icon.png b/onedrive_integration_odoo/static/description/icon.png new file mode 100644 index 000000000..9f529e47c Binary files /dev/null and b/onedrive_integration_odoo/static/description/icon.png differ diff --git a/onedrive_integration_odoo/static/description/index.html b/onedrive_integration_odoo/static/description/index.html new file mode 100644 index 000000000..c4ddb2fbe --- /dev/null +++ b/onedrive_integration_odoo/static/description/index.html @@ -0,0 +1,961 @@ + + + + + + Odoo App 3 Index + + + + + + + + +
+
+
+
+
+ +
+
+
+ Community +
+
+ Enterprise +
+
+ Odoo.sh +
+
+
+
+
+
+

+ Onedrive Integration

+

+ Onedrive Integration Allows to Upload and Download the Files + in Microsoft OneDrive. +

+
+ +
+
+
+
+
+

+ Key Highlights +

+
+
+
+
+
+ +
+
+

+ Easy File Management.

+
+
+
+
+
+
+ +
+
+

+ Displays all files on Onedrive.

+
+
+
+
+
+
+ +
+
+

+ Upload files to Onedrive.

+
+
+
+
+
+
+ +
+
+

+ Filter files on basis of file type.

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

+ Onedrive api creation

+

+ To create Onedrive api register application + on Microsoft Azure. + Go to App registrations > New + registration

+

Give the Redirect URI as base url + + /onedrive/authentication and click on + Register button

+
+
+
+
+
+
+ +
+
+

+ Onedrive client id

+

+ Registering on Microsoft Azure --> app + registration will get Application + (client) + ID and Client credentials +

+
+
+
+
+
+
+ +
+
+

+ Onedrive client secret

+

+ Client secret is available on client + credentials option. It will be shown only + once so, need to save it somewhere safe.

+
+
+
+
+
+
+ +
+
+

+ Onedrive Scopes.

+

+ Need to add scopes offline_access, openid, + Files.ReadWrite.All to get refresh token and + read write access + Application ID URI will also set

+
+
+
+
+
+
+ +
+
+

+ Scope added with openid

+
+
+
+
+
+
+ +
+
+

+ Onedrive Folder id

+

+ The Onedrive folder id is presented on url + of that folder itself once we select the + folder with datas

+
+
+
+
+
+
+ +
+
+

+ Microsoft OneDrive Token setup

+

+ Token setup is available in configuration + settings. Setup Tokens button will redirect + to an authorization page.

+

+ Go to --> Settngs-->Integrations +

+
+
+
+
+
+
+ +
+
+

+ Login to microsoft to get auth code

+
+
+
+
+
+
+ +
+
+

+

+

+

+
+
+
+
+
+
+ +
+
+

+ Onedrive Integration view

+
+
+
+
+
+
+ +
+
+

+ Filter View

+

+ Example for Image filter +

+
+
+
+
+
+
+ +
+
+

+ Filter View

+

+ Example for PDF filter +

+
+
+
+
+
+
+ +
+
+

+ Filter View

+

+ Example for excel filter +

+
+
+
+
+
+
+ +
+
+

+ Upload Files

+

+ Wizard to upload files. We can upload files + from odoo to get listed inside one drive and + upload files in one drive to be seen inside + odoo. +

+
+
+
+
+
+
+ +
+
+

+ Import Files

+

+ On Clicking Import button onedrive files + will come inside odoo +

+
+
+
+
+
+
+
    +
  • + Integrating OneDrive with Odoo +
  • +
  • + Store and access their files within the Odoo platform. +
  • +
  • + Upload files to Onedrive +
  • +
  • + Onedrive Integration +
      +
    • OneDrive is a cloud-based file storage + and sharing service from Microsoft. + Integrating OneDrive with Odoo can + provide users with a more convenient way + to store and access their files within + the Odoo platform. + +
    • +
    +
  • +
+
+
+
+
+
+
Version + 17.0.1.0.0|Released on:24th January 2024 +
+

+ Initial Commit for Onedrive Integration +

+
+
+
+
+
+
+
+

+ Related Products

+
+
+ +
+
+

+ Our Services

+
+
+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Customization

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Implementation

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Support

+
+
+
+
+
+
+ service-icon +
+
+

Hire + Odoo Developer

+
+
+
+
+ +
+
+ service-icon +
+
+

Odoo + Integration

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Migration

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Consultancy

+
+
+
+
+
+
+ service-icon +
+
+

Odoo + Implementation

+
+
+
+
+
+
+ service-icon +
+
+

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

+
+
+
+
+
+
+

+ Support

+
+
+
+
+
+
+
+ +
+ Need + Help? +

Got + questions or need help? Get in touch.

+
odoo@cybrosys.com +
+
+
+
+
+
+
+
+ +
+ WhatsApp +

Say hi to + us on WhatsApp!

+
+91 + 99456767686 +
+
+
+
+
+
+
+
+
+ + + + + + diff --git a/onedrive_integration_odoo/static/src/img/excel.png b/onedrive_integration_odoo/static/src/img/excel.png new file mode 100644 index 000000000..eabf40713 Binary files /dev/null and b/onedrive_integration_odoo/static/src/img/excel.png differ diff --git a/onedrive_integration_odoo/static/src/img/file.png b/onedrive_integration_odoo/static/src/img/file.png new file mode 100644 index 000000000..5071e38b3 Binary files /dev/null and b/onedrive_integration_odoo/static/src/img/file.png differ diff --git a/onedrive_integration_odoo/static/src/img/file_icon.png b/onedrive_integration_odoo/static/src/img/file_icon.png new file mode 100644 index 000000000..cd449fd2b Binary files /dev/null and b/onedrive_integration_odoo/static/src/img/file_icon.png differ diff --git a/onedrive_integration_odoo/static/src/img/image.png b/onedrive_integration_odoo/static/src/img/image.png new file mode 100644 index 000000000..75a40a64b Binary files /dev/null and b/onedrive_integration_odoo/static/src/img/image.png differ diff --git a/onedrive_integration_odoo/static/src/img/microsoft-onedrive.svg b/onedrive_integration_odoo/static/src/img/microsoft-onedrive.svg new file mode 100644 index 000000000..385cd98b9 --- /dev/null +++ b/onedrive_integration_odoo/static/src/img/microsoft-onedrive.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/onedrive_integration_odoo/static/src/img/onedrive_name.svg b/onedrive_integration_odoo/static/src/img/onedrive_name.svg new file mode 100644 index 000000000..4efaae0fe --- /dev/null +++ b/onedrive_integration_odoo/static/src/img/onedrive_name.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/onedrive_integration_odoo/static/src/img/pdf.png b/onedrive_integration_odoo/static/src/img/pdf.png new file mode 100644 index 000000000..e970c4eb6 Binary files /dev/null and b/onedrive_integration_odoo/static/src/img/pdf.png differ diff --git a/onedrive_integration_odoo/static/src/img/sync.svg b/onedrive_integration_odoo/static/src/img/sync.svg new file mode 100644 index 000000000..10b61b665 --- /dev/null +++ b/onedrive_integration_odoo/static/src/img/sync.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/onedrive_integration_odoo/static/src/img/txt.png b/onedrive_integration_odoo/static/src/img/txt.png new file mode 100644 index 000000000..4f94a3144 Binary files /dev/null and b/onedrive_integration_odoo/static/src/img/txt.png differ diff --git a/onedrive_integration_odoo/static/src/img/word.png b/onedrive_integration_odoo/static/src/img/word.png new file mode 100644 index 000000000..465797064 Binary files /dev/null and b/onedrive_integration_odoo/static/src/img/word.png differ diff --git a/onedrive_integration_odoo/static/src/img/zip.png b/onedrive_integration_odoo/static/src/img/zip.png new file mode 100644 index 000000000..e5d0a9b2b Binary files /dev/null and b/onedrive_integration_odoo/static/src/img/zip.png differ diff --git a/onedrive_integration_odoo/static/src/js/onedrive.js b/onedrive_integration_odoo/static/src/js/onedrive.js new file mode 100644 index 000000000..27cf0aa7b --- /dev/null +++ b/onedrive_integration_odoo/static/src/js/onedrive.js @@ -0,0 +1,110 @@ +/** @odoo-modules */ +import { registry } from "@web/core/registry"; +import { useService } from "@web/core/utils/hooks"; +import { Component } from "@odoo/owl"; +import { jsonrpc } from "@web/core/network/rpc_service"; +const actionRegistry = registry.category("actions"); +import { useRef } from "@odoo/owl"; +class OnedriveDashboard extends Component{ +setup() { + super.setup(); + this.orm = useService("orm"); + this.action = useService("action"); + this.inputRef = useRef("all_files"); + this.synchronize(); + } +// * Opens a file upload dialog on click of the "Upload" button. +// * +// * @param {Object} ev - The click event object. +// */ + async upload(){ + this.action.doAction({ + name: "Upload File", + type: 'ir.actions.act_window', + res_model: 'upload.file', + view_mode: 'form', + view_type: 'form', + views: [[false, 'form']], + target: 'new', + }); + } + /** + * Retrieves and displays files from OneDrive on click of the "Import" button. + * + * @param {Object} ev - The click event object. + */ + async synchronize(){ + var self = this; + var result = await this.orm.call('onedrive.dashboard', + "action_synchronize_onedrive",[' ']) + if (!result) { + this.action.doAction({ + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'message': 'Please setup credentials', + 'type': 'warning', + 'sticky': false, + } + }); + } + else if (result[0] === 'error') { + if (result[1] === 'itemNotFound') { + // Display a notification if the folder is not found + this.action.doAction({ + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'message': 'Error: Folder not found.', + 'type': 'warning', + 'sticky': false, + } + }); + } + else { + // Display a notification for other errors + this.action.doAction({ + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'message': 'Error:' + result[2], + 'type': 'warning', + 'sticky': false, + } + }); + } + } else { + // Empty the onedrive_files div and append the files retrieved + this.inputRef.el.innerHTML = ''; + var alt_src = "'/onedrive_integration_odoo/static/src/img/file_icon.png'"; + $.each(Object.keys(result), function (index, name) { + $('#onedrive_files').append(''); + }); + } + } + /** + * Filters files displayed based on file type (e.g., image, all files). + * + * @param {Object} ev - The click event object. + */ + async filter_file_type(ev) { + var value = ev.currentTarget.getAttribute('value'); + $.each($('.card'), function (index, name) { + $(this).hide(); + var file_type = (name.textContent).slice(((name.textContent).lastIndexOf(".") - 1 >>> 0) + 2); + if (file_type == value) { + $(this).show(); + } + if (value == 'allfiles') { + $(this).show(); + } + if (value == 'image') { + if (file_type == 'jpeg' || file_type == 'jpg' || file_type == 'png') { + $(this).show(); + } + } + }); + } + } +OnedriveDashboard.template = "OnedriveDashboard"; +registry.category("actions").add("onedrive_dashboard", OnedriveDashboard) diff --git a/onedrive_integration_odoo/static/src/scss/onedrive.scss b/onedrive_integration_odoo/static/src/scss/onedrive.scss new file mode 100644 index 000000000..6b3c2c93e --- /dev/null +++ b/onedrive_integration_odoo/static/src/scss/onedrive.scss @@ -0,0 +1,44 @@ +.left-sidebar { + background-color: #0529ac; + color: white; + border-radius: 5px; + width: 110px; +} +.files{ + margin-top: 20px; + } +.file-icon{ + width: 65px; + margin-top: 42px; + margin-left: 5px; +} +.image{ + opacity: 80%; + width: 55px; + margin-left: 10px; +} +.card-img-top{ + width: 180px; + height: 180px; +} +.import{ + background-color: #ffffff; + color: #0529ac; + border-radius: 5px; + width: 100px; + border-color: unset; + margin-left: 10px +} +.upload{ + background-color: #0529ac; + color: white; + border-radius: 5px; + width: 100px; + margin-left: 10px; +} +.card{ + max-width: 15%; + height: 23rem; + border-radius: 1.25rem; + margin: 15px; +} diff --git a/onedrive_integration_odoo/static/src/xml/onedrive_dashboard.xml b/onedrive_integration_odoo/static/src/xml/onedrive_dashboard.xml new file mode 100644 index 000000000..357ead1e7 --- /dev/null +++ b/onedrive_integration_odoo/static/src/xml/onedrive_dashboard.xml @@ -0,0 +1,61 @@ + + + diff --git a/onedrive_integration_odoo/views/onedrive_dashboard_views.xml b/onedrive_integration_odoo/views/onedrive_dashboard_views.xml new file mode 100644 index 000000000..2dd9e887c --- /dev/null +++ b/onedrive_integration_odoo/views/onedrive_dashboard_views.xml @@ -0,0 +1,14 @@ + + + + + OneDrive Dashboard + onedrive_dashboard + current + + + + diff --git a/onedrive_integration_odoo/views/res_config_settings_views.xml b/onedrive_integration_odoo/views/res_config_settings_views.xml new file mode 100644 index 000000000..f5613a08f --- /dev/null +++ b/onedrive_integration_odoo/views/res_config_settings_views.xml @@ -0,0 +1,54 @@ + + + + + res.config.settings.inherit.view.onedrive.integration.odoo + res.config.settings + + + + +
+
+ +
+
+
+
+ + Client ID: + + +
+
+ + Client Secret: + + +
+ +
+ + Folder ID: + + +
+
+
+
+
+
diff --git a/onedrive_integration_odoo/wizard/__init__.py b/onedrive_integration_odoo/wizard/__init__.py new file mode 100644 index 000000000..73a646acb --- /dev/null +++ b/onedrive_integration_odoo/wizard/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Jumana Haseen ( odoo@cybrosys.com ) +# +# 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 upload_file diff --git a/onedrive_integration_odoo/wizard/upload_file.py b/onedrive_integration_odoo/wizard/upload_file.py new file mode 100644 index 000000000..fedfa5924 --- /dev/null +++ b/onedrive_integration_odoo/wizard/upload_file.py @@ -0,0 +1,83 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Jumana Haseen ( odoo@cybrosys.com ) +# +# 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 requests +from odoo import exceptions, fields, models, _ + + +class UploadFile(models.TransientModel): + """ + For opening wizard view + """ + _name = "upload.file" + _description = "Upload File" + + file = fields.Binary(string="Attachment", help="Select a file to upload") + file_name = fields.Char(string="File Name", help="Name of the attachment") + + def action_upload_file(self): + """ + Upload file to onedrive + """ + if not self.file: + raise exceptions.UserError(_('Please Attach a file to upload.')) + attachment = self.env["ir.attachment"].search( + ['|', ('res_field', '!=', False), ('res_field', '=', False), + ('res_id', '=', self.id), + ('res_model', '=', 'upload.file')]) + token = self.env['onedrive.dashboard'].search([], order='id desc', + limit=1) + folder = self.env['ir.config_parameter'].get_param( + 'onedrive_integration_odoo.folder_id', '') + if not token or not folder: + raise exceptions.UserError( + _('Please setup Access Token and Folder Id.')) + if token.token_expiry_date <= str(fields.Datetime.now()): + token.generate_onedrive_refresh_token() + try: + url = "http://graph.microsoft.com/v1.0/me/drive/items/%s:/%s:/" \ + "createUploadSession" % (folder, self.file_name) + upload_session = requests.post(url, headers={ + 'Content-Type': 'application/json', + 'Authorization': 'Bearer "' + token.onedrive_access_token + '"' + }) + requests.put(upload_session.json().get('uploadUrl'), data=open( + (attachment._full_path(attachment.store_fname)), 'rb')) + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'type': 'success', + 'message': 'File has been uploaded successfully. ' + 'Please refresh.', + 'next': {'type': 'ir.actions.act_window_close'}, + } + } + except Exception as error: + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'type': 'warning', + 'message': 'Failed to upload: %s' % error, + 'next': {'type': 'ir.actions.act_window_close'}, + } + } diff --git a/onedrive_integration_odoo/wizard/upload_file_views.xml b/onedrive_integration_odoo/wizard/upload_file_views.xml new file mode 100644 index 000000000..6729a2d50 --- /dev/null +++ b/onedrive_integration_odoo/wizard/upload_file_views.xml @@ -0,0 +1,31 @@ + + + + + upload.file.view.form + upload.file + +
+ + + + +
+
+
+
+
+ + + Select a File + ir.actions.act_window + upload.file + form + + new + +