diff --git a/onedrive_integration_odoo/README.rst b/onedrive_integration_odoo/README.rst new file mode 100644 index 000000000..c4815ef2f --- /dev/null +++ b/onedrive_integration_odoo/README.rst @@ -0,0 +1,54 @@ +.. image:: https://img.shields.io/badge/licence-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 + +Installation +============ +- www.odoo.com/documentation/15.0/setup/install.html +- Install our custom addon + +License +------- +General Public License, Version 3 (AGPL v3). +(https://www.gnu.org/licenses/agpl-3.0-standalone.html) + +Company +------- +* `Cybrosys Techno Solutions `__ + +Credits +------- +* Developer: (V15) Aslam A K, 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: ``__ diff --git a/onedrive_integration_odoo/__init__.py b/onedrive_integration_odoo/__init__.py new file mode 100644 index 000000000..155e3ab31 --- /dev/null +++ b/onedrive_integration_odoo/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies(). +# Author: Aslam A K( 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..a71086ead --- /dev/null +++ b/onedrive_integration_odoo/__manifest__.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies(). +# Author: Aslam A K( 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': "15.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', + 'views/onedrive_dashboard_views.xml', + 'views/res_config_settings_views.xml', + 'wizard/upload_file_views.xml' + ], + 'assets': { + 'web.assets_backend': [ + '/onedrive_integration_odoo/static/src/js/onedrive.js', + '/onedrive_integration_odoo/static/src/scss/onedrive.scss' + ], + 'web.assets_qweb': [ + '/onedrive_integration_odoo/static/src/xml/onedrive_dashboard_templates.xml', + ], + }, + 'images': ['static/description/banner.png'], + 'uninstall_hook': 'uninstall_hook', + 'license': 'AGPL-3', + 'installable': True, + 'application': True, + 'auto_install': False, +} diff --git a/onedrive_integration_odoo/controllers/__init__.py b/onedrive_integration_odoo/controllers/__init__.py new file mode 100644 index 000000000..cfc7e599d --- /dev/null +++ b/onedrive_integration_odoo/controllers/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies(). +# Author: Aslam A K( 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..7cd5579f5 --- /dev/null +++ b/onedrive_integration_odoo/controllers/onedrive_integration_odoo.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies(). +# Author: Aslam A K( 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): + """ Controller to return URL """ + + @http.route('/onedrive/authentication', type='http', auth="public") + def oauth2callback(self, **kw): + """ Function to return URL for authentication """ + 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..a4661cf32 --- /dev/null +++ b/onedrive_integration_odoo/doc/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 14.09.2023 +#### Version 15.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..75d0bc710 --- /dev/null +++ b/onedrive_integration_odoo/hooks.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies(). +# Author: Aslam A K( 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..c6cd5f081 --- /dev/null +++ b/onedrive_integration_odoo/models/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies(). +# Author: Aslam A K( 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..213fa09b4 --- /dev/null +++ b/onedrive_integration_odoo/models/onedrive_dashboard.py @@ -0,0 +1,143 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies(). +# Author: Aslam A K( 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): + """Model for generating refresh and access tokens for OneDrive.""" + + _name = 'onedrive.dashboard' + _description = "OneDrive Dashboard" + + onedrive_access_token = fields.Char(string="OneDrive Access Token", + store=True, + help="Access token for OneDrive API " + "authentication") + onedrive_refresh_token = fields.Char(string="OneDrive Refresh Token", + help="Refresh token for obtaining " + "new access tokens") + token_expiry_date = fields.Char(string="OneDrive Token Validity", + help="Validity or expiration status of the" + " OneDrive access token") + upload_file = fields.Binary(string="Upload File", + help="Binary data of the file to be uploaded " + "to OneDrive") + + 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..12ed59007 --- /dev/null +++ b/onedrive_integration_odoo/models/res_config_settings.py @@ -0,0 +1,107 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies(). +# Author: Aslam A K( 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): + _inherit = 'res.config.settings' + + onedrive_client = fields.Char( + string='Onedrive Client ID', + copy=False, + config_parameter='onedrive_integration_odoo.client_id', + help='The Onedrive client ID from the Developer credentials.') + onedrive_client_secret = fields.Char( + string='Onedrive Client Secret', + config_parameter='onedrive_integration_odoo.client_secret', + help='The Onedrive client secret from Developer credentials.') + onedrive_access_token = fields.Char( + string='Onedrive Access Token', + help='Access token generated from onedrive') + onedrive_refresh_token = fields.Char( + string='Onedrive Refresh Token', + help='Refresh token generated from onedrive') + token_expiry_date = fields.Datetime( + string='Onedrive Token Validity', + help='Access token expiry date') + onedrive_folder = fields.Char( + string='Folder ID', + config_parameter='onedrive_integration_odoo.folder_id', + help='Onedrive Folder Id from url') + is_onedrive_integration = fields.Boolean( + string='Onedrive Cloud Storage', + config_parameter='onedrive_integration_odoo.onedrive_button', + default=False, + help="Login to Microsoft to get access token") + + 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..0a48859fa --- /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,access.onedrive.dashboard,model_onedrive_dashboard,base.group_user,1,1,1,1 +access_upload_file,access.upload.file,model_upload_file,base.group_user,1,1,1,1 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/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/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/categories.png b/onedrive_integration_odoo/static/description/assets/misc/categories.png new file mode 100644 index 000000000..bedf1e0b1 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/misc/categories.png differ diff --git a/onedrive_integration_odoo/static/description/assets/misc/check-box.png b/onedrive_integration_odoo/static/description/assets/misc/check-box.png new file mode 100644 index 000000000..42caf24b9 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/misc/check-box.png differ diff --git a/onedrive_integration_odoo/static/description/assets/misc/compass.png b/onedrive_integration_odoo/static/description/assets/misc/compass.png new file mode 100644 index 000000000..d5fed8faa Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/misc/compass.png differ diff --git a/onedrive_integration_odoo/static/description/assets/misc/corporate.png b/onedrive_integration_odoo/static/description/assets/misc/corporate.png new file mode 100644 index 000000000..2eb13edbf Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/misc/corporate.png differ diff --git a/onedrive_integration_odoo/static/description/assets/misc/customer-support.png b/onedrive_integration_odoo/static/description/assets/misc/customer-support.png new file mode 100644 index 000000000..79efc72ed Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/misc/customer-support.png differ diff --git a/onedrive_integration_odoo/static/description/assets/misc/cybrosys-logo.png b/onedrive_integration_odoo/static/description/assets/misc/cybrosys-logo.png new file mode 100644 index 000000000..cc3cc0ccf Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/misc/cybrosys-logo.png differ diff --git a/onedrive_integration_odoo/static/description/assets/misc/features.png b/onedrive_integration_odoo/static/description/assets/misc/features.png new file mode 100644 index 000000000..b41769f77 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/misc/features.png differ diff --git a/onedrive_integration_odoo/static/description/assets/misc/logo.png b/onedrive_integration_odoo/static/description/assets/misc/logo.png new file mode 100644 index 000000000..478462d3e Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/misc/logo.png differ diff --git a/onedrive_integration_odoo/static/description/assets/misc/pictures.png b/onedrive_integration_odoo/static/description/assets/misc/pictures.png new file mode 100644 index 000000000..56d255fe9 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/misc/pictures.png differ diff --git a/onedrive_integration_odoo/static/description/assets/misc/pie-chart.png b/onedrive_integration_odoo/static/description/assets/misc/pie-chart.png new file mode 100644 index 000000000..426e05244 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/misc/pie-chart.png differ diff --git a/onedrive_integration_odoo/static/description/assets/misc/right-arrow.png b/onedrive_integration_odoo/static/description/assets/misc/right-arrow.png new file mode 100644 index 000000000..730984a06 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/misc/right-arrow.png differ diff --git a/onedrive_integration_odoo/static/description/assets/misc/star.png b/onedrive_integration_odoo/static/description/assets/misc/star.png new file mode 100644 index 000000000..2eb9ab29f Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/misc/star.png differ diff --git a/onedrive_integration_odoo/static/description/assets/misc/support.png b/onedrive_integration_odoo/static/description/assets/misc/support.png new file mode 100644 index 000000000..4f18b8b82 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/misc/support.png differ diff --git a/onedrive_integration_odoo/static/description/assets/misc/whatsapp.png b/onedrive_integration_odoo/static/description/assets/misc/whatsapp.png new file mode 100644 index 000000000..d513a5356 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/misc/whatsapp.png differ diff --git a/onedrive_integration_odoo/static/description/assets/modules/1.gif b/onedrive_integration_odoo/static/description/assets/modules/1.gif new file mode 100644 index 000000000..591c8b18d Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/modules/1.gif 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..f5174ab22 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..a0969fcb5 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.gif b/onedrive_integration_odoo/static/description/assets/modules/4.gif new file mode 100644 index 000000000..c51b9eb07 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/modules/4.gif 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..903a921af 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..929f992f7 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/1.png b/onedrive_integration_odoo/static/description/assets/screenshots/1.png new file mode 100644 index 000000000..bed68a581 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/1.png differ diff --git a/onedrive_integration_odoo/static/description/assets/screenshots/10.png b/onedrive_integration_odoo/static/description/assets/screenshots/10.png new file mode 100644 index 000000000..cc7d3dece Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/10.png differ diff --git a/onedrive_integration_odoo/static/description/assets/screenshots/11.png b/onedrive_integration_odoo/static/description/assets/screenshots/11.png new file mode 100644 index 000000000..53553a986 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/11.png differ diff --git a/onedrive_integration_odoo/static/description/assets/screenshots/12.png b/onedrive_integration_odoo/static/description/assets/screenshots/12.png new file mode 100644 index 000000000..8d3ebdb38 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/12.png differ diff --git a/onedrive_integration_odoo/static/description/assets/screenshots/2.png b/onedrive_integration_odoo/static/description/assets/screenshots/2.png new file mode 100644 index 000000000..6f135aab4 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/2.png differ diff --git a/onedrive_integration_odoo/static/description/assets/screenshots/3.png b/onedrive_integration_odoo/static/description/assets/screenshots/3.png new file mode 100644 index 000000000..3b55a7764 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/3.png differ diff --git a/onedrive_integration_odoo/static/description/assets/screenshots/4.png b/onedrive_integration_odoo/static/description/assets/screenshots/4.png new file mode 100644 index 000000000..d021dce5c Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/4.png differ diff --git a/onedrive_integration_odoo/static/description/assets/screenshots/5.png b/onedrive_integration_odoo/static/description/assets/screenshots/5.png new file mode 100644 index 000000000..40906e5bf Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/5.png differ diff --git a/onedrive_integration_odoo/static/description/assets/screenshots/6.png b/onedrive_integration_odoo/static/description/assets/screenshots/6.png new file mode 100644 index 000000000..b2caee3ec Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/6.png differ diff --git a/onedrive_integration_odoo/static/description/assets/screenshots/7.png b/onedrive_integration_odoo/static/description/assets/screenshots/7.png new file mode 100644 index 000000000..6aaac571d Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/7.png differ diff --git a/onedrive_integration_odoo/static/description/assets/screenshots/8.png b/onedrive_integration_odoo/static/description/assets/screenshots/8.png new file mode 100644 index 000000000..80bf7c37e Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/8.png differ diff --git a/onedrive_integration_odoo/static/description/assets/screenshots/9.png b/onedrive_integration_odoo/static/description/assets/screenshots/9.png new file mode 100644 index 000000000..3aec8a8ac Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/9.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..9d5be9e01 Binary files /dev/null and b/onedrive_integration_odoo/static/description/assets/screenshots/hero.gif 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..a845426b0 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..821d5f151 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..658800111 --- /dev/null +++ b/onedrive_integration_odoo/static/description/index.html @@ -0,0 +1,788 @@ +
+ +
+ +
+
+ Community +
+
+ Enterprise +
+
+ Odoo.sh +
+
+
+ + + +
+
+
+

+ Onedrive Integration

+

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

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

+ Explore This + Module

+
+ + + + +
+
+ +
+

+ Overview +

+
+
+
+ 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. +
+
+ + + +
+
+ +
+

+ Features +

+
+
+
+
+ + Easy File Management +
+ +
+ + Displays all files on Onedrive +
+ +
+ + Upload files to Onedrive +
+ +
+ + Filter files on basis of file type +
+
+
+ + + +
+
+ +
+

+ Screenshots +

+
+
+
+ +
+

+ Onedrive Api Creation +

+

+ Create Onedrive api register application on + Microsoft Azure Portal. Give the Redirect URI as base url with + /onedrive/authentication. Eg: http://localhost:8015/onedrive/authentication

+ +
+ +
+

+ Onedrive Client Id +

+

+ Registering on Microsoft Azure --> app registration + will get + client id and credentials

+ +
+ +
+

+ Onedrive Client Secret +

+

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

+ +
+ +
+

+ Onedrive Scopes +

+

+ Need to add scopes offline_access, openid, + Files.ReadWrite.All + to get refresh token and read write access

+ +
+
+

+ Onedrive Folder Id +

+

+ The Onedrive folder id is presented on url of that + folder + itself.

+ +
+ +
+

+ Token Setup +

+

+ Token setup is available in configuration settings. + Setup + Tokens button will redirect to an authorization + page. + Goto --> Settngs-->Integrations

+ +
+ +
+

+

+

+ Login to microsoft to get auth code

+ +
+ +
+

+

+

+

+ +
+ +
+

+ Onedrive Integration View

+

+

+ +
+ +
+

+ Filter View

+

+ Example For Excel Filter +

+ +
+ +
+

+ Filter View

+

+ Example For ZIP Filter +

+ +
+ +
+

+ Upload Files

+

+ Wizard to Upload Files +

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

+ 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

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

+ Support +

+
+
+
+
+
+
+ +
+
+

Need Help?

+

Got questions or + need help? + Get in touch.

+ +

+ odoo@cybrosys.com

+
+
+
+
+
+
+
+ +
+
+

WhatsApp

+

Say hi to us on + WhatsApp!

+ +

+ +91 86068 27707

+
+
+
+
+
+
+
+ +
+
+
+ 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..f65472632 --- /dev/null +++ b/onedrive_integration_odoo/static/src/js/onedrive.js @@ -0,0 +1,106 @@ +odoo.define('onedrive_integration_odoo.dashboard', function (require) { + 'use strict'; + var AbstractAction = require('web.AbstractAction'); + var core = require('web.core'); + var _t = core._t; + var rpc = require('web.rpc'); + var OnedriveDashboard = AbstractAction.extend({ + template: 'OnedriveDashboard', + events: { + 'click #import': 'synchronize', + 'click #upload': 'upload', + 'click .file-type': 'filter_file_type' + }, + init() { + this._super(...arguments); + var self = this; + self.synchronize(); + }, + // Calls upload function on click of upload + upload: function (ev) { + this.do_action({ + name: "Upload File", + type: 'ir.actions.act_window', + res_model: 'upload.file', + view_mode: 'form', + view_type: 'form', + views: [[false, 'form']], + target: 'new', + }); + }, + // Appends files retrieved by function(action_synchronize_onedrive) to div onedrive_files on click of import + synchronize: function (ev) { + var self = this; + rpc.query({ + model: 'onedrive.dashboard', + method: 'action_synchronize_onedrive', + args: [''] + }).then(function (result) { + if (!result) { + // Display a notification if access tokens are not set up + self.do_action({ + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'message': _t('Please setup credentials'), + 'type': 'warning', + 'sticky': false, + } + }); + } else if (result[0] === 'error') { + console.log(result); + if (result[1] === 'itemNotFound') { + // Display a notification if the folder is not found + self.do_action({ + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'message': _t('Error: Folder not found.'), + 'type': 'warning', + 'sticky': false, + } + }); + } else { + // Display a notification for other errors + self.do_action({ + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'message': _t('Error:' + result[2]), + 'type': 'warning', + 'sticky': false, + } + }); + } + } else { + // Empty the onedrive_files div and append the files retrieved + self.$('#onedrive_files').empty(); + var alt_src = "'/onedrive_integration_odoo/static/src/img/file_icon.png'"; + $.each(Object.keys(result), function (index, name) { + self.$('#onedrive_files').append('
' + name + '
'); + }); + } + }); + }, + filter_file_type: function (ev) { + var value = ev.currentTarget.getAttribute('value'); + $.each(this.$('.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(); + } + } + }); + }, + }); + core.action_registry.add("onedrive_dashboard", OnedriveDashboard); + return 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..6655747c1 --- /dev/null +++ b/onedrive_integration_odoo/static/src/scss/onedrive.scss @@ -0,0 +1,49 @@ +.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: 1.1vw; +} +.card{ + max-width: 15%; + height: 23rem; + border-radius: 1.25rem; + margin: 15px; +} +.image{ + opacity: 80%; + width: 55px; + margin-left: 1.3vw; +} +.card-img-top{ + width: 10vw; + height: 22vh; +} +.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; +} +.onedrive_content{ +overflow-y: scroll; +height: 85vh; +background-color:lightgray; +} \ No newline at end of file diff --git a/onedrive_integration_odoo/static/src/xml/onedrive_dashboard_templates.xml b/onedrive_integration_odoo/static/src/xml/onedrive_dashboard_templates.xml new file mode 100644 index 000000000..831aa5ce6 --- /dev/null +++ b/onedrive_integration_odoo/static/src/xml/onedrive_dashboard_templates.xml @@ -0,0 +1,47 @@ + + + \ No newline at end of file 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..de55dca97 --- /dev/null +++ b/onedrive_integration_odoo/views/onedrive_dashboard_views.xml @@ -0,0 +1,13 @@ + + + + + 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..8f5130111 --- /dev/null +++ b/onedrive_integration_odoo/views/res_config_settings_views.xml @@ -0,0 +1,60 @@ + + + + + + res.config.settings.view.form.inherit.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..30e2ef784 --- /dev/null +++ b/onedrive_integration_odoo/wizard/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies(). +# Author: Aslam A K( 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..261a4c6d6 --- /dev/null +++ b/onedrive_integration_odoo/wizard/upload_file.py @@ -0,0 +1,90 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies(). +# Author: Aslam A K( 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): + """ Model for opening the file upload 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 file to upload") + + def action_upload_file(self): + """Upload file to OneDrive.""" + if not self.file: + raise exceptions.UserError(_('Please attach a file to upload.')) + # Searching for attachments related to the current upload.file record + attachment = self.env["ir.attachment"].search( + ['|', ('res_field', '!=', False), ('res_field', '=', False), + ('res_id', '=', self.id), + ('res_model', '=', 'upload.file')]) + # Getting the access token and folder ID from the onedrive.dashboard + # and ir.config_parameter models + 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 set up Access Token and Folder ID.')) + # Refreshing the token if it has expired + if token.token_expiry_date <= str(fields.Datetime.now()): + token.generate_onedrive_refresh_token() + try: + # Creating an upload session for the file + 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 + '"' + }) + upload_url = upload_session.json().get('uploadUrl') + # Uploading the file to the upload session URL + requests.put(upload_url, data=open( + (attachment._full_path(attachment.store_fname)), 'rb')) + # Returning a success notification + 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: + # Returning a warning notification if the upload fails + 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..1b1ca472a --- /dev/null +++ b/onedrive_integration_odoo/wizard/upload_file_views.xml @@ -0,0 +1,24 @@ + + + + + upload.file.view.form + upload.file + +
+ + + + + +
+
+
+