diff --git a/odoo_database_restore_manager/README.rst b/odoo_database_restore_manager/README.rst new file mode 100644 index 000000000..ac9805021 --- /dev/null +++ b/odoo_database_restore_manager/README.rst @@ -0,0 +1,53 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +Database Restore Manager +======================== +All the database backups that are stored by module auto_database_backup can be +restored using this module + +Configuration +============= +The auto_database_backup module should be installed +( Here is the link: https://apps.odoo.com/apps/modules/16.0/auto_database_backup/ ) +All the requirements for auto_database_backup module should be installed. + +Installation +============ +- www.odoo.com/documentation/16.0/setup/install.html +- Install our custom addon + +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, 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/odoo_database_restore_manager/__init__.py b/odoo_database_restore_manager/__init__.py new file mode 100644 index 000000000..3e121b6a1 --- /dev/null +++ b/odoo_database_restore_manager/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Aslam AK (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################### +from . import models +from . import wizard diff --git a/odoo_database_restore_manager/__manifest__.py b/odoo_database_restore_manager/__manifest__.py new file mode 100644 index 000000000..a068d98d9 --- /dev/null +++ b/odoo_database_restore_manager/__manifest__.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Aslam AK (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################### +{ + 'name': "Database Restore Manager Odoo16", + 'version': "16.0.1.0.0'", + 'category': "Extra Tools", + 'summary': """Easily Restore The Previous Database Backups Stored in Different Locations like Google Drive, + Dropbox, Onedrive, Nextcloud and Amazon S3""", + 'description': """TEasily Restore The Previous Database Backups Stored in Different Locations like Google Drive, + Dropbox, Onedrive, Nextcloud and Amazon S3, backup, automatic backup""", + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': "https://www.cybrosys.com", + 'depends': ['base_setup', 'auto_database_backup'], + 'data': [ + 'security/ir.model.access.csv', + 'views/database_manager_views.xml', + 'views/res_config_settings_views.xml', + 'wizard/database_restore_views.xml' + ], + 'assets': { + 'web.assets_backend': [ + '/odoo_database_restore_manager/static/src/js/db_restore.js', + '/odoo_database_restore_manager/static/src/xml/db_restore_dashboard_templates.xml', + '/odoo_database_restore_manager/static/src/scss/db_restore.scss' + ] + }, + 'external_dependencies': {'python': ['dropbox', 'gdown']}, + 'images': ['static/description/banner.png'], + 'license': 'LGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/odoo_database_restore_manager/doc/RELEASE_NOTES.md b/odoo_database_restore_manager/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..d9231b3af --- /dev/null +++ b/odoo_database_restore_manager/doc/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 05.01.2024 +#### Version 16.0.1.0.0 +#### ADD +- Initial commit for Database Restore Manager diff --git a/odoo_database_restore_manager/models/__init__.py b/odoo_database_restore_manager/models/__init__.py new file mode 100644 index 000000000..d745467f2 --- /dev/null +++ b/odoo_database_restore_manager/models/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Aslam AK (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################### +from . import database_manager +from . import res_config_settings diff --git a/odoo_database_restore_manager/models/database_manager.py b/odoo_database_restore_manager/models/database_manager.py new file mode 100644 index 000000000..03d2c8f31 --- /dev/null +++ b/odoo_database_restore_manager/models/database_manager.py @@ -0,0 +1,271 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Aslam AK (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################### +import boto3 +import dropbox +import ftplib +import nextcloud_client +import os +import paramiko +import requests +from odoo.http import request +from datetime import datetime +from odoo import fields, models + + +class DatabaseManager(models.Model): + """ Dashboard model to view all database backups """ + _name = 'database.manager' + _description = 'Database Manager' + + def action_import_files(self): + """ Import latest backups from the storages configured """ + return_data = {} + backup_count = int(self.env['ir.config_parameter'].get_param( + 'odoo_database_restore_manager.backup_count')) + current_company = request.httprequest.cookies.get('cids')[0] + # Check if backup_count is less than or equal to 0 + if backup_count <= 0: + return ['error', 'Please set a backup count', 'Storages', + current_company] + # Check if any backups are configured in the database + if not self.env['db.backup.configure'].search([]): + return ['error', 'No Backups Found', 'auto_database_backup', + current_company] + # Loop through each configured backup source + for rec in self.env['db.backup.configure'].search([]): + if rec.backup_destination == 'dropbox': + try: + # Retrieve backups from Dropbox and update the return_data + # dictionary with the latest backups + dbx_dict = {} + dbx = dropbox.Dropbox(app_key=rec.dropbox_client_key, + app_secret=rec.dropbox_client_secret, + oauth2_refresh_token= + rec.dropbox_refresh_token) + response = dbx.files_list_folder(path=rec.dropbox_folder) + for files in response.entries: + file = dbx.files_get_temporary_link( + path=files.path_lower) + dbx_dict[file.metadata.name] = file.link, 'Dropbox', \ + files.client_modified + return_data.update(dict(list(sorted(dbx_dict.items(), + key=lambda x: x[1][2], + reverse=True))[ + :backup_count])) + except Exception as e: + # Handle any exceptions that occur during Dropbox backup + # retrieval + return ['error', e, 'Dropbox', current_company] + if rec.backup_destination == 'onedrive': + try: + # Retrieve backups from OneDrive and update the return_data + # dictionary with the latest backups + onedrive_dict = {} + if rec.onedrive_token_validity <= fields.Datetime.now(): + rec.generate_onedrive_refresh_token() + url = "https://graph.microsoft.com/v1.0/me/drive/items/" \ + "%s/children?Content-Type=application/json" \ + % rec.onedrive_folder_key + response = requests.request("GET", url, headers={ + 'Authorization': 'Bearer "' + rec.onedrive_access_token + + '"'}, data={}) + for file in response.json().get('value'): + if list(file.keys())[ + 0] == '@microsoft.graph.downloadUrl': + onedrive_dict[file['name']] = file[ + '@microsoft.graph.downloadUrl'], 'OneDrive', \ + datetime.strptime( + file['createdDateTime'], + "%Y-%m-%dT%H:%M:%S.%fZ").strftime( + "%Y-%m-%d %H:%M:%S") + return_data.update(dict(list(sorted(onedrive_dict.items(), + key=lambda x: x[1][2], + reverse=True))[ + :backup_count])) + except Exception as e: + # Handle any exceptions that occur during OneDrive backup + # retrieval + return ['error', e, 'OneDrive', current_company] + if rec.backup_destination == 'google_drive': + try: + # Retrieve backups from Google Drive and update the + # return_data dictionary with the latest backups + gdrive_dict = {} + if rec.gdrive_token_validity <= fields.Datetime.now(): + rec.generate_gdrive_refresh_token() + response = requests.get( + f"https://www.googleapis.com/drive/v3/files", + headers={ + "Authorization": "Bearer %s" % rec.gdrive_access_token + }, + params={ + "q": f"'{rec.google_drive_folder_key}' in parents", + "fields": "files(name, webContentLink, createdTime)", + }) + for file_data in response.json().get("files", []): + gdrive_dict[file_data.get("name")] = file_data.get( + "webContentLink"), 'Google Drive', \ + datetime.strptime(file_data.get("createdTime"), + "%Y-%m-%dT%H:%M:%S.%fZ").strftime( + "%Y-%m-%d %H:%M:%S") + return_data.update(dict(list(sorted(gdrive_dict.items(), + key=lambda x: x[1][2], + reverse=True))[ + :backup_count])) + except Exception as e: + # Handle any exceptions that occur during Google Drive + # backup retrieval + return ['error', e, 'Google Drive', current_company] + if rec.backup_destination == 'local': + try: + # Retrieve backups from Local Storage and update the + # return_data dictionary with the latest backups + local_dict = {} + for root, dirs, files in os.walk(rec.backup_path): + for file in files: + file_path = os.path.join(root, file) + create_date = datetime.fromtimestamp( + os.path.getctime(file_path)).strftime( + "%Y-%m-%d %H:%M:%S") + local_dict[file] = file_path, 'Local Storage', \ + create_date + return_data.update(dict(list(sorted(local_dict.items(), + key=lambda x: x[1][2], + reverse=True))[ + :backup_count])) + except Exception as e: + # Handle any exceptions that occur during Local Storage + # backup retrieval + return ['error', e, 'Local', current_company] + if rec.backup_destination == 'ftp': + try: + # Retrieve backups from FTP Storage and update the + # return_data dictionary with the latest backups + ftp_dict = {} + ftp_server = ftplib.FTP() + ftp_server.connect(rec.ftp_host, int(rec.ftp_port)) + ftp_server.login(rec.ftp_user, rec.ftp_password) + for file in ftp_server.nlst(rec.ftp_path): + file_details = ftp_server.voidcmd("MDTM " + file) + ftp_dict[os.path.basename( + file)] = file, 'FTP Storage', datetime.strptime( + file_details[4:].strip(), "%Y%m%d%H%M%S") + ftp_server.quit() + return_data.update(dict(list(sorted(ftp_dict.items(), + key=lambda x: x[1][2], + reverse=True))[ + :backup_count])) + except Exception as e: + # Handle any exceptions that occur during FTP Storage + # backup retrieval + return ['error', e, 'FTP server', current_company] + if rec.backup_destination == 'sftp': + sftp_client = paramiko.SSHClient() + sftp_client.set_missing_host_key_policy( + paramiko.AutoAddPolicy()) + try: + # Retrieve backups from SFTP Storage and update the + # return_data dictionary with the latest backups + sftp_dict = {} + sftp_client.connect(hostname=rec.sftp_host, + username=rec.sftp_user, + password=rec.sftp_password, + port=rec.sftp_port) + sftp_server = sftp_client.open_sftp() + sftp_server.chdir(rec.sftp_path) + file_list = sftp_server.listdir() + for file_name in file_list: + sftp_dict[file_name] = os.path.join(rec.sftp_path, + file_name), \ + 'SFTP Storage', datetime.fromtimestamp( + sftp_server.stat(file_name).st_mtime) + sftp_server.close() + return_data.update(dict(list(sorted(sftp_dict.items(), + key=lambda x: x[1][2], + reverse=True))[ + :backup_count])) + except Exception as e: + # Handle any exceptions that occur during SFTP Storage + # backup retrieval + return ['error', e, 'SFTP server', current_company] + finally: + sftp_client.close() + if rec.backup_destination == 'next_cloud': + try: + nxt_dixt = {} + nc_access = nextcloud_client.Client(rec.domain) + nc_access.login(rec.next_cloud_user_name, + rec.next_cloud_password) + for file_name in [file.name for file in + nc_access.list( + '/' + rec.nextcloud_folder_key)]: + link_info = nc_access.share_file_with_link( + '/' + rec.nextcloud_folder_key + '/' + file_name, + publicUpload=False) + file_info = nc_access.file_info( + '/' + rec.nextcloud_folder_key + '/' + file_name) + input_datetime = datetime.strptime( + file_info.attributes['{DAV:}getlastmodified'], + "%a, %d %b %Y %H:%M:%S %Z") + output_date_str = input_datetime.strftime( + "%Y-%m-%d %H:%M:%S") + nxt_dixt[ + file_name] = link_info.get_link() + '/download', 'Nextcloud', output_date_str + return_data.update(dict(list(sorted(nxt_dixt.items(), + key=lambda x: x[1][2], + reverse=True))[ + :backup_count])) + except Exception as e: + # Handle any exceptions that occur during SFTP Storage + # backup retrieval + return ['error', e, 'Nextcloud', current_company] + if rec.backup_destination == 'amazon_s3': + try: + s3_dixt = {} + client = boto3.client('s3', aws_access_key_id=rec.aws_access_key, + aws_secret_access_key=rec.aws_secret_access_key) + region = client.get_bucket_location(Bucket=rec.bucket_file_name) + client = boto3.client( + 's3', region_name=region['LocationConstraint'], + aws_access_key_id=rec.aws_access_key, + aws_secret_access_key=rec.aws_secret_access_key + ) + response = client.list_objects(Bucket=rec.bucket_file_name, Prefix=rec.aws_folder_name) + for data in response['Contents']: + if data['Size'] != 0: + url = client.generate_presigned_url( + ClientMethod='get_object', + Params={'Bucket': rec.bucket_file_name, + 'Key': data['Key']},ExpiresIn=3600) + s3_dixt[data['Key']] = url, 'AmazonS3', data['LastModified'] + return_data.update(dict(list(sorted(s3_dixt.items(), + key=lambda x: x[1][2], + reverse=True))[ + :backup_count])) + except Exception as e: + # Handle any exceptions that occur during amazon_s3 Storage + # backup retrieval + return ['error', e, 'Amazon S3', current_company] + + # Return the dictionary containing the latest backups from all + # configured sources + return [return_data, current_company] diff --git a/odoo_database_restore_manager/models/res_config_settings.py b/odoo_database_restore_manager/models/res_config_settings.py new file mode 100644 index 000000000..ea12e5487 --- /dev/null +++ b/odoo_database_restore_manager/models/res_config_settings.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Aslam AK (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################### +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + """ Configure the number of backups for restore """ + _inherit = 'res.config.settings' + + backup_count = fields.Integer(string='Backup Count', + help='Number of backups to list for restore', + config_parameter= + 'odoo_database_restore_manager.backup_count') diff --git a/odoo_database_restore_manager/security/ir.model.access.csv b/odoo_database_restore_manager/security/ir.model.access.csv new file mode 100644 index 000000000..be25286e1 --- /dev/null +++ b/odoo_database_restore_manager/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_database_manager,access.database_manager,model_database_manager,base.group_user,1,1,1,1 +access_database_restore,access.database_restore,model_database_restore,base.group_user,1,1,1,1 diff --git a/odoo_database_restore_manager/static/description/assets/icons/check.png b/odoo_database_restore_manager/static/description/assets/icons/check.png new file mode 100644 index 000000000..c8e85f51d Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/check.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/chevron.png b/odoo_database_restore_manager/static/description/assets/icons/chevron.png new file mode 100644 index 000000000..2089293d6 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/chevron.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/cogs.png b/odoo_database_restore_manager/static/description/assets/icons/cogs.png new file mode 100644 index 000000000..95d0bad62 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/cogs.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/consultation.png b/odoo_database_restore_manager/static/description/assets/icons/consultation.png new file mode 100644 index 000000000..8319d4baa Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/consultation.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/ecom-black.png b/odoo_database_restore_manager/static/description/assets/icons/ecom-black.png new file mode 100644 index 000000000..a9385ff13 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/ecom-black.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/education-black.png b/odoo_database_restore_manager/static/description/assets/icons/education-black.png new file mode 100644 index 000000000..3eb09b27b Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/education-black.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/hotel-black.png b/odoo_database_restore_manager/static/description/assets/icons/hotel-black.png new file mode 100644 index 000000000..130f613be Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/hotel-black.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/license.png b/odoo_database_restore_manager/static/description/assets/icons/license.png new file mode 100644 index 000000000..a5869797e Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/license.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/lifebuoy.png b/odoo_database_restore_manager/static/description/assets/icons/lifebuoy.png new file mode 100644 index 000000000..658d56ccc Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/lifebuoy.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/manufacturing-black.png b/odoo_database_restore_manager/static/description/assets/icons/manufacturing-black.png new file mode 100644 index 000000000..697eb0e9f Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/manufacturing-black.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/pos-black.png b/odoo_database_restore_manager/static/description/assets/icons/pos-black.png new file mode 100644 index 000000000..97c0f90c1 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/pos-black.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/puzzle.png b/odoo_database_restore_manager/static/description/assets/icons/puzzle.png new file mode 100644 index 000000000..65cf854e7 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/puzzle.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/restaurant-black.png b/odoo_database_restore_manager/static/description/assets/icons/restaurant-black.png new file mode 100644 index 000000000..4a35eb939 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/restaurant-black.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/service-black.png b/odoo_database_restore_manager/static/description/assets/icons/service-black.png new file mode 100644 index 000000000..301ab51cb Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/service-black.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/trading-black.png b/odoo_database_restore_manager/static/description/assets/icons/trading-black.png new file mode 100644 index 000000000..9398ba2f1 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/trading-black.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/training.png b/odoo_database_restore_manager/static/description/assets/icons/training.png new file mode 100644 index 000000000..884ca024d Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/training.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/update.png b/odoo_database_restore_manager/static/description/assets/icons/update.png new file mode 100644 index 000000000..ecbc5a01a Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/update.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/user.png b/odoo_database_restore_manager/static/description/assets/icons/user.png new file mode 100644 index 000000000..6ffb23d9f Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/user.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/wrench.png b/odoo_database_restore_manager/static/description/assets/icons/wrench.png new file mode 100644 index 000000000..6c04dea0f Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/wrench.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/categories.png b/odoo_database_restore_manager/static/description/assets/misc/categories.png new file mode 100644 index 000000000..bedf1e0b1 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/categories.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/check-box.png b/odoo_database_restore_manager/static/description/assets/misc/check-box.png new file mode 100644 index 000000000..42caf24b9 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/check-box.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/compass.png b/odoo_database_restore_manager/static/description/assets/misc/compass.png new file mode 100644 index 000000000..d5fed8faa Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/compass.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/corporate.png b/odoo_database_restore_manager/static/description/assets/misc/corporate.png new file mode 100644 index 000000000..2eb13edbf Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/corporate.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/customer-support.png b/odoo_database_restore_manager/static/description/assets/misc/customer-support.png new file mode 100644 index 000000000..79efc72ed Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/customer-support.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/cybrosys-logo.png b/odoo_database_restore_manager/static/description/assets/misc/cybrosys-logo.png new file mode 100644 index 000000000..cc3cc0ccf Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/cybrosys-logo.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/features.png b/odoo_database_restore_manager/static/description/assets/misc/features.png new file mode 100644 index 000000000..b41769f77 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/features.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/logo.png b/odoo_database_restore_manager/static/description/assets/misc/logo.png new file mode 100644 index 000000000..478462d3e Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/logo.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/pictures.png b/odoo_database_restore_manager/static/description/assets/misc/pictures.png new file mode 100644 index 000000000..56d255fe9 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/pictures.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/pie-chart.png b/odoo_database_restore_manager/static/description/assets/misc/pie-chart.png new file mode 100644 index 000000000..426e05244 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/pie-chart.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/right-arrow.png b/odoo_database_restore_manager/static/description/assets/misc/right-arrow.png new file mode 100644 index 000000000..730984a06 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/right-arrow.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/star.png b/odoo_database_restore_manager/static/description/assets/misc/star.png new file mode 100644 index 000000000..2eb9ab29f Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/star.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/support.png b/odoo_database_restore_manager/static/description/assets/misc/support.png new file mode 100644 index 000000000..4f18b8b82 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/support.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/whatsapp.png b/odoo_database_restore_manager/static/description/assets/misc/whatsapp.png new file mode 100644 index 000000000..d513a5356 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/whatsapp.png differ diff --git a/odoo_database_restore_manager/static/description/assets/modules/1.gif b/odoo_database_restore_manager/static/description/assets/modules/1.gif new file mode 100644 index 000000000..beb106101 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/modules/1.gif differ diff --git a/odoo_database_restore_manager/static/description/assets/modules/2.png b/odoo_database_restore_manager/static/description/assets/modules/2.png new file mode 100644 index 000000000..cbcc848e2 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/modules/2.png differ diff --git a/odoo_database_restore_manager/static/description/assets/modules/3.png b/odoo_database_restore_manager/static/description/assets/modules/3.png new file mode 100644 index 000000000..ed11bd818 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/modules/3.png differ diff --git a/odoo_database_restore_manager/static/description/assets/modules/4.png b/odoo_database_restore_manager/static/description/assets/modules/4.png new file mode 100644 index 000000000..a3194264c Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/modules/4.png differ diff --git a/odoo_database_restore_manager/static/description/assets/modules/5.png b/odoo_database_restore_manager/static/description/assets/modules/5.png new file mode 100644 index 000000000..1c98e213f Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/modules/5.png differ diff --git a/odoo_database_restore_manager/static/description/assets/modules/6.png b/odoo_database_restore_manager/static/description/assets/modules/6.png new file mode 100644 index 000000000..eb3f8652f Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/modules/6.png differ diff --git a/odoo_database_restore_manager/static/description/assets/screenshots/1.png b/odoo_database_restore_manager/static/description/assets/screenshots/1.png new file mode 100644 index 000000000..2fbb39b74 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/screenshots/1.png differ diff --git a/odoo_database_restore_manager/static/description/assets/screenshots/2.png b/odoo_database_restore_manager/static/description/assets/screenshots/2.png new file mode 100644 index 000000000..de944b259 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/screenshots/2.png differ diff --git a/odoo_database_restore_manager/static/description/assets/screenshots/3.png b/odoo_database_restore_manager/static/description/assets/screenshots/3.png new file mode 100644 index 000000000..b0d8e21d9 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/screenshots/3.png differ diff --git a/odoo_database_restore_manager/static/description/assets/screenshots/4.png b/odoo_database_restore_manager/static/description/assets/screenshots/4.png new file mode 100644 index 000000000..fb99ee969 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/screenshots/4.png differ diff --git a/odoo_database_restore_manager/static/description/assets/screenshots/5.png b/odoo_database_restore_manager/static/description/assets/screenshots/5.png new file mode 100644 index 000000000..02fcaf39c Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/screenshots/5.png differ diff --git a/odoo_database_restore_manager/static/description/assets/screenshots/6.png b/odoo_database_restore_manager/static/description/assets/screenshots/6.png new file mode 100644 index 000000000..d8ccbbad1 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/screenshots/6.png differ diff --git a/odoo_database_restore_manager/static/description/assets/screenshots/7.png b/odoo_database_restore_manager/static/description/assets/screenshots/7.png new file mode 100644 index 000000000..23402d6f1 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/screenshots/7.png differ diff --git a/odoo_database_restore_manager/static/description/assets/screenshots/hero.gif b/odoo_database_restore_manager/static/description/assets/screenshots/hero.gif new file mode 100644 index 000000000..3e438d94e Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/screenshots/hero.gif differ diff --git a/odoo_database_restore_manager/static/description/banner.png b/odoo_database_restore_manager/static/description/banner.png new file mode 100644 index 000000000..efcb45e3a Binary files /dev/null and b/odoo_database_restore_manager/static/description/banner.png differ diff --git a/odoo_database_restore_manager/static/description/icon.png b/odoo_database_restore_manager/static/description/icon.png new file mode 100644 index 000000000..62624f305 Binary files /dev/null and b/odoo_database_restore_manager/static/description/icon.png differ diff --git a/odoo_database_restore_manager/static/description/index.html b/odoo_database_restore_manager/static/description/index.html new file mode 100644 index 000000000..0c55c8773 --- /dev/null +++ b/odoo_database_restore_manager/static/description/index.html @@ -0,0 +1,716 @@ +
+ +
+ +
+
+ Community +
+
+ Enterprise +
+
+
+ +
+
+
+ +

+ Database Restore Manager

+

+ Easily Restore The Previous Database Backups Stored in Different Locations like Google Drive, + Dropbox, Onedrive, Nextcloud and Amazon S3 +

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

+ Explore This + Module

+
+ + + + +
+
+ +
+

+ Overview +

+
+
+
+ Database Restore Manager enhances the database restoration process + by seamlessly restoring database backups that were previously uploaded + to different storage locations using the " + auto_database_backup " module. + With the Database Restore Manager, users can effortlessly restore + their Odoo databases from previously created backups. It simplifies the + restoration process and provides a centralized interface to manage and + restore backups stored in various locations. + The app integrates seamlessly with the "auto_database_backup" module, + which automatically creates backups of Odoo databases and uploads them + to different storage options such as local directories, FTP servers, + SFTP servers, Google Drive, Dropbox, and OneDrive. By utilizing + the auto_database_backup module, users can schedule regular backups and + store them in diverse storage locations for enhanced data protection. +
+
+ + + +
+
+ +
+

+ Features +

+
+
+
+
+ + Easy and Flexible Restoration +
+ +
+ + Restore Previous Database from Google Drive +
+ +
+ + Restore Previous Database from Dropbox +
+ +
+ + Restore Previous Database from Onedrive +
+
+ + Restore Previous Database from Google Drive +
+
+ + Restore Previous Database from Nextcloud +
+
+ + Restore Previous Database from Amazon S3 +
+
+
+ + + +
+
+ +
+

+ Screenshots +

+
+
+
+
+

+ Configure backups by + Automatic Database Backup Module. +

+

+ Go to Settings->> Technical->> Backup Configuration to set up + Database backups +

+ +
+ +
+

+ Configure the Number of latest backups to be shown +

+

+

+ +
+ + +
+

+ Database Restore Manager View +

+

+

+ +
+ +
+

+ Filter on storage location and Restore button +

+

+ +

+ +
+

+ Restoring Database Backup +

+

+ New Database name and Master password +

+ +
+ +
+

+ Restore complete +

+

+

+ +
+ +
+

+ Download backups +

+

+

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

+ 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

+
+
+
+
+
+
+
+ +
+
+
+ \ No newline at end of file diff --git a/odoo_database_restore_manager/static/src/img/odoo_logo.png b/odoo_database_restore_manager/static/src/img/odoo_logo.png new file mode 100644 index 000000000..dc9ab9a3c Binary files /dev/null and b/odoo_database_restore_manager/static/src/img/odoo_logo.png differ diff --git a/odoo_database_restore_manager/static/src/img/restore.png b/odoo_database_restore_manager/static/src/img/restore.png new file mode 100644 index 000000000..2b15683fc Binary files /dev/null and b/odoo_database_restore_manager/static/src/img/restore.png differ diff --git a/odoo_database_restore_manager/static/src/js/db_restore.js b/odoo_database_restore_manager/static/src/js/db_restore.js new file mode 100644 index 000000000..39abdf4f2 --- /dev/null +++ b/odoo_database_restore_manager/static/src/js/db_restore.js @@ -0,0 +1,79 @@ +odoo.define('odoo_database_restore_manager.dashboard', function (require) { + 'use strict'; + var AbstractAction = require('web.AbstractAction'); + var core = require('web.core'); + var rpc = require('web.rpc'); + var DbRestoreDashboard = AbstractAction.extend({ + template: 'DbRestoreDashboard', + events: { + 'click #db_restore' : 'restore', + 'change #db_location' : 'filter_location', + }, + /* Appends backups retrieved by function(action_import_files) to div db_restore_files */ + init() { + this._super(...arguments); + var self=this; + rpc.query({ + model: 'database.manager', + method: 'action_import_files', + args: [''] + }).then(function(result) { + if (result[0] == 'error') { + self.$el.find('.company_image').append('') + self.do_action({ + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'message': 'Failed to Load Files from ' + result[2] + ' [ ' + result[1] + ' ]', + 'type': 'warning', + 'sticky': false, + } + }); + } else { + var count = 1; + self.$el.find('.company_image').append('') + _.each(result[0], function(name, index) { + var downloadBackup = ''; + if (['Dropbox', 'OneDrive', 'Google Drive' , 'Nextcloud', 'AmazonS3'].includes(name[1])) { + downloadBackup = ' '; + } + self.$el.find('.db_restore_files').append('' + count + '' + index + '' + name[1] + '' + name[2] + '' + downloadBackup + ''); + count++; + }); + } + }) + }, +/* Open up the wizard to restore the selected backup file */ + restore: function(ev) { + this.do_action({ + name: "Restore Database", + type: 'ir.actions.act_window', + res_model: 'database.restore', + view_mode: 'form', + view_type: 'form', + views: [[false, 'form']], + context: { + default_db_file: ev.target.getAttribute('value'), + default_backup_location: this.$(ev.target).closest('tr').find('td').eq(2).text() + }, + target: 'new', + }); + }, +/* Filter backups based on storage types */ + filter_location: function(ev) { + var e = this.$el.find("#db_location").get(0); + var self = this; + this.$el.find('.file_row').each(function(index, name) { + self.$(this).hide(); + var location = self.$(name).find('td').eq(2).text(); + if (e.value === 'all_backups') { + self.$(this).show(); + } else if (e.value === location) { + self.$(this).show(); + } + }); + }, + }); + core.action_registry.add("database_manager_dashboard", DbRestoreDashboard); + return DbRestoreDashboard; +}); diff --git a/odoo_database_restore_manager/static/src/scss/db_restore.scss b/odoo_database_restore_manager/static/src/scss/db_restore.scss new file mode 100644 index 000000000..95fe0da0b --- /dev/null +++ b/odoo_database_restore_manager/static/src/scss/db_restore.scss @@ -0,0 +1,60 @@ +#db_location { + outline: none; + border: none; + font-size: 15px; + box-shadow: none; + background-color: #fff; + padding: 4px 24px; + height: 40px; +} +.db_restore_content { + height: 100%; + width: 100%; +} +#db_restore { + color: #ffffff; + width: 90px; + background-color: #b1b1b1; + height: 30px; + border: none; + text-transform: capitalize; +} +#db_restore:hover { + background-color: #000; + color: #fff; +} +.backup_download { + color: #ffffff; + width: 30px; + background-color: #b1b1b1; + height: 30px; + border: none; + text-transform: capitalize; +} +.backup_download:hover { + background-color: #000; + color: #fff; +} +.table-head { + background-color: #2e2e2e; + color: #fff; + border: 1px solid #eaeaea; +} +.file_row { + --table-bg: #ffffff; + color: #000; + border: 1px solid #eaeaea; +} +.scrollable-table { + height: 75vh; + overflow-y: auto; +} +.company_image { + max-width: 200px; + max-height: 100px; + margin: 20px; +} +.option { + background-color: black; + color: white; +} diff --git a/odoo_database_restore_manager/static/src/xml/db_restore_dashboard_templates.xml b/odoo_database_restore_manager/static/src/xml/db_restore_dashboard_templates.xml new file mode 100644 index 000000000..3aa948f2e --- /dev/null +++ b/odoo_database_restore_manager/static/src/xml/db_restore_dashboard_templates.xml @@ -0,0 +1,62 @@ + + + diff --git a/odoo_database_restore_manager/views/database_manager_views.xml b/odoo_database_restore_manager/views/database_manager_views.xml new file mode 100644 index 000000000..72f0cf48f --- /dev/null +++ b/odoo_database_restore_manager/views/database_manager_views.xml @@ -0,0 +1,13 @@ + + + + + Database Restore Manager + database_manager_dashboard + current + + + diff --git a/odoo_database_restore_manager/views/res_config_settings_views.xml b/odoo_database_restore_manager/views/res_config_settings_views.xml new file mode 100644 index 000000000..b3e70a29f --- /dev/null +++ b/odoo_database_restore_manager/views/res_config_settings_views.xml @@ -0,0 +1,25 @@ + + + + + + res.config.settings.view.form.inherit.odoo.database.restore.manager + + res.config.settings + + + +
+
+
+
+
+ + + + diff --git a/odoo_database_restore_manager/wizard/__init__.py b/odoo_database_restore_manager/wizard/__init__.py new file mode 100644 index 000000000..36ab568e1 --- /dev/null +++ b/odoo_database_restore_manager/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 database_restore diff --git a/odoo_database_restore_manager/wizard/database_restore.py b/odoo_database_restore_manager/wizard/database_restore.py new file mode 100644 index 000000000..49c1a84d3 --- /dev/null +++ b/odoo_database_restore_manager/wizard/database_restore.py @@ -0,0 +1,115 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Aslam AK (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################### +import ftplib +import gdown +import os +import paramiko +import requests +import tempfile +import odoo +import odoo.modules.registry +from odoo import fields, models +from odoo.exceptions import UserError +from odoo.http import dispatch_rpc +from odoo.service import db +from odoo.tools.misc import str2bool + + +class DataBaseRestore(models.TransientModel): + """ Database Restore Model """ + _name = "database.restore" + _description = "Database Restore" + + db_file = fields.Char(string="File", help="Restore database file") + db_name = fields.Char(string="Database Name", help="Name of the database") + db_master_pwd = fields.Char(string="Database Master Password", + help="Master Password to restore database") + backup_location = fields.Char(string="Backup Location", + help="Database backup location") + + def action_restore_database(self, copy=False): + """ Function to restore the database Backup """ + # Check if the admin password is insecure and update it if provided + insecure = odoo.tools.config.verify_admin_password('admin') + if insecure and self.db_master_pwd: + dispatch_rpc('db', 'change_admin_password', + ["admin", self.db_master_pwd]) + try: + # Check if the admin password is correct and proceed with the + # restore process + db.check_super(self.db_master_pwd) + # Create a temporary file to store the downloaded backup data + temp_file = tempfile.NamedTemporaryFile(delete=False) + if self.backup_location == 'Google Drive': + # Retrieve backup from Google Drive using gdown library + gdown.download(self.db_file, temp_file.name, quiet=False) + elif self.backup_location in ['Dropbox', 'OneDrive', 'Nextcloud', 'AmazonS3']: + # Retrieve backup from Dropbox or OneDrive using requests + # library + response = requests.get(self.db_file, stream=True) + temp_file.write(response.content) + elif self.backup_location == 'FTP Storage': + # Retrieve backup from FTP Storage using ftplib + for rec in self.env['db.backup.configure'].search([]): + if rec.backup_destination == 'ftp' and rec.ftp_path == \ + os.path.dirname(self.db_file): + ftp_server = ftplib.FTP() + ftp_server.connect(rec.ftp_host, int(rec.ftp_port)) + ftp_server.login(rec.ftp_user, rec.ftp_password) + ftp_server.retrbinary("RETR " + self.db_file, + temp_file.write) + temp_file.seek(0) + ftp_server.quit() + elif self.backup_location == 'SFTP Storage': + # Retrieve backup from SFTP Storage using paramiko + for rec in self.env['db.backup.configure'].search([]): + if rec.backup_destination == 'sftp' and rec.sftp_path == \ + os.path.dirname(self.db_file): + sftp_client = paramiko.SSHClient() + sftp_client.set_missing_host_key_policy( + paramiko.AutoAddPolicy()) + sftp_client.connect(hostname=rec.sftp_host, + username=rec.sftp_user, + password=rec.sftp_password, + port=rec.sftp_port) + sftp_server = sftp_client.open_sftp() + sftp_server.getfo(self.db_file, temp_file) + sftp_server.close() + sftp_client.close() + elif self.backup_location == 'Local Storage': + # If the backup is stored in the local storage, set the temp + # file's name accordingly + temp_file.name = self.db_file + # Restore the database using Odoo's 'restore_db' method + db.restore_db(self.db_name, temp_file.name, str2bool(copy)) + temp_file.close() + # Redirect the user to the Database Manager after successful + # restore + return { + 'type': 'ir.actions.act_url', + 'url': '/web/database/manager' + } + except Exception as e: + # Raise a UserError if any error occurs during the database + # restore process + raise UserError( + "Database re2store error: %s" % (str(e) or repr(e))) diff --git a/odoo_database_restore_manager/wizard/database_restore_views.xml b/odoo_database_restore_manager/wizard/database_restore_views.xml new file mode 100644 index 000000000..2ef9117c1 --- /dev/null +++ b/odoo_database_restore_manager/wizard/database_restore_views.xml @@ -0,0 +1,24 @@ + + + + + database.restore.view.form + database.restore + +
+ + + + + +
+
+
+