Browse Source

[UPDT] Aug 20 : Automatic database backup to Onedrive

pull/219/head
AjmalCybro 3 years ago
parent
commit
171bded0d9
  1. 1
      auto_database_backup/__init__.py
  2. 7
      auto_database_backup/__manifest__.py
  3. 21
      auto_database_backup/controllers/__init__.py
  4. 35
      auto_database_backup/controllers/main.py
  5. 9
      auto_database_backup/data/data.xml
  6. 7
      auto_database_backup/doc/RELEASE_NOTES.md
  7. 144
      auto_database_backup/models/db_backup_configure.py
  8. BIN
      auto_database_backup/static/description/assets/icons/onedrive.png
  9. BIN
      auto_database_backup/static/description/assets/screenshots/dropbox1.png
  10. BIN
      auto_database_backup/static/description/assets/screenshots/dropbox2.png
  11. BIN
      auto_database_backup/static/description/assets/screenshots/dropbox3.png
  12. BIN
      auto_database_backup/static/description/assets/screenshots/dropbox4.png
  13. BIN
      auto_database_backup/static/description/assets/screenshots/onedrive1.png
  14. BIN
      auto_database_backup/static/description/assets/screenshots/onedrive2.png
  15. BIN
      auto_database_backup/static/description/assets/screenshots/onedrive3.png
  16. BIN
      auto_database_backup/static/description/assets/screenshots/onedrive4.png
  17. BIN
      auto_database_backup/static/description/assets/screenshots/onedrive5.png
  18. BIN
      auto_database_backup/static/description/assets/screenshots/onedrive6.png
  19. BIN
      auto_database_backup/static/description/assets/screenshots/onedrive7.png
  20. BIN
      auto_database_backup/static/description/assets/screenshots/onedrive8.png
  21. BIN
      auto_database_backup/static/description/assets/screenshots/onedrive9.png
  22. BIN
      auto_database_backup/static/description/banner.gif
  23. 116
      auto_database_backup/static/description/index.html
  24. 25
      auto_database_backup/views/db_backup_configure_views.xml

1
auto_database_backup/__init__.py

@ -20,3 +20,4 @@
from . import models
from . import wizard
from . import controllers

7
auto_database_backup/__manifest__.py

@ -22,8 +22,8 @@
{
'name': "Automatic Database Backup To Local Server, Remote Server, Google Drive And Dropbox",
'version': '15.0.2.0.1',
'summary': """Generate automatic backup of databases and store to local, google drive, dropbox or remote server""",
'version': '15.0.3.0.1',
'summary': """Generate automatic backup of databases and store to local, google drive, dropbox, onedrive or remote server""",
'description': """This module has been developed for creating database backups automatically
and store it to the different locations.""",
'author': "Cybrosys Techno Solutions",
@ -36,8 +36,9 @@
'security/ir.model.access.csv',
'data/data.xml',
'views/db_backup_configure_views.xml',
'wizard/dropbox_authcode_wizard_views.xml'
'wizard/dropbox_authcode_wizard_views.xml',
],
'external_dependencies': {'python': ['dropbox']},
'license': 'LGPL-3',
'images': ['static/description/banner.gif'],
'installable': True,

21
auto_database_backup/controllers/__init__.py

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2022-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
from . import main

35
auto_database_backup/controllers/main.py

@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2022-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
import json
from odoo import http
from odoo.http import request
class OnedriveAuth(http.Controller):
@http.route('/onedrive/authentication', type='http', auth="public")
def oauth2callback(self, **kw):
state = json.loads(kw['state'])
backup_config = request.env['db.backup.configure'].sudo().browse(state.get('backup_config_id'))
backup_config.get_onedrive_tokens(kw.get('code'))
url_return = state.get('url_return')
return request.redirect(url_return)

9
auto_database_backup/data/data.xml

@ -51,6 +51,9 @@
<t t-elif="object.backup_destination == 'dropbox'">
<i>Dropbox</i>
</t>
<t t-elif="object.backup_destination == 'onedrive'">
<i>Onedrive</i>
</t>
.
<br/>
<br/>
@ -72,6 +75,9 @@
</t>
<t t-elif="object.backup_destination == 'dropbox'">
Dropbox
</t>
<t t-elif="object.backup_destination == 'onedrive'">
Onedrive
</t>
<t t-if="object.backup_destination in ('local', 'ftp', 'sftp', 'dropbox')">
<br/>
@ -138,6 +144,9 @@
</t>
<t t-elif="object.backup_destination == 'dropbox'">
Dropbox
</t>
<t t-elif="object.backup_destination == 'onedrive'">
Onedrive
</t>
<t t-if="object.backup_destination in ('local', 'ftp', 'sftp', 'dropbox')">
<br/>

7
auto_database_backup/doc/RELEASE_NOTES.md

@ -6,7 +6,12 @@
- Initial commit for auto_database_backup
#### 14.06.2022
#### Version 15.0.1.0.1
#### Version 15.0.2.0.1
#### ADD
- Dropbox integration added. Backup can be stored in to dropbox.
#### 20.08.2022
#### Version 15.0.3.0.1
#### ADD
- Onedrive integration added. Backup can be stored in to onedrive.

144
auto_database_backup/models/db_backup_configure.py

@ -24,9 +24,13 @@ from odoo import models, fields, api, _
from odoo.exceptions import UserError, ValidationError
import odoo
from odoo.service import db
from odoo.http import request
import dropbox
from werkzeug import urls
from datetime import timedelta
import datetime
import os
import paramiko
@ -39,6 +43,9 @@ import logging
_logger = logging.getLogger(__name__)
ONEDRIVE_SCOPE = ['offline_access openid Files.ReadWrite.All']
MICROSOFT_GRAPH_END_POINT = "https://graph.microsoft.com"
class AutoDatabaseBackup(models.Model):
_name = 'db.backup.configure'
@ -56,7 +63,8 @@ class AutoDatabaseBackup(models.Model):
('google_drive', 'Google Drive'),
('ftp', 'FTP'),
('sftp', 'SFTP'),
('dropbox', 'Dropbox')
('dropbox', 'Dropbox'),
('onedrive', 'Onedrive')
], string='Backup Destination')
backup_path = fields.Char(string='Backup Path', help='Local storage directory path')
sftp_host = fields.Char(string='SFTP Host')
@ -84,6 +92,22 @@ class AutoDatabaseBackup(models.Model):
user_id = fields.Many2one('res.users', string='User')
backup_filename = fields.Char(string='Backup Filename', help='For Storing generated backup filename')
generated_exception = fields.Char(string='Exception', help='Exception Encountered while Backup generation')
onedrive_client_id = fields.Char(string='Onedrive Client ID', copy=False)
onedrive_client_secret = fields.Char(string='Onedrive Client Secret', compy=False)
onedrive_access_token = fields.Char(string='Onedrive Access Token', copy=False)
onedrive_refresh_token = fields.Char(string='Onedrive Refresh Token', copy=False)
onedrive_token_validity = fields.Datetime(string='Onedrive Token Validity', copy=False)
onedrive_folder_id = fields.Char(string='Folder ID')
is_onedrive_token_generated = fields.Boolean(string='onedrive Tokens Generated',
compute='_compute_is_onedrive_token_generated', copy=False)
@api.depends('onedrive_access_token', 'onedrive_refresh_token')
def _compute_is_onedrive_token_generated(self):
"""
Set true if onedrive tokens are generated
"""
for rec in self:
rec.is_onedrive_token_generated = bool(rec.onedrive_access_token) and bool(rec.onedrive_refresh_token)
@api.depends('dropbox_refresh_token')
def _compute_is_dropbox_token_generated(self):
@ -95,7 +119,7 @@ class AutoDatabaseBackup(models.Model):
def action_get_dropbox_auth_code(self):
"""
Open a wizard to setup dropbox Authorization code
Open a wizard to set up dropbox Authorization code
"""
return {
'type': 'ir.actions.act_window',
@ -105,6 +129,92 @@ class AutoDatabaseBackup(models.Model):
'target': 'new',
}
def action_get_onedrive_auth_code(self):
"""
Generate onedrive authorization code
"""
AUTHORITY = 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize'
action = self.env["ir.actions.act_window"].sudo()._for_xml_id("auto_database_backup.action_db_backup_configure")
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'], 'db.backup.configure')
state = {
'backup_config_id': self.id,
'url_return': url_return
}
encoded_params = urls.url_encode({
'response_type': 'code',
'client_id': self.onedrive_client_id,
'state': json.dumps(state),
'scope': ONEDRIVE_SCOPE,
'redirect_uri': base_url + '/onedrive/authentication',
'prompt': 'consent',
'access_type': 'offline'
})
auth_url = "%s?%s" % (AUTHORITY, encoded_params)
return {
'type': 'ir.actions.act_url',
'target': 'self',
'url': auth_url,
}
def generate_onedrive_refresh_token(self):
"""
generate onedrive access token from refresh token if expired
"""
base_url = request.env['ir.config_parameter'].get_param('web.base.url')
headers = {"Content-type": "application/x-www-form-urlencoded"}
data = {
'client_id': self.onedrive_client_id,
'client_secret': self.onedrive_client_secret,
'scope': ONEDRIVE_SCOPE,
'grant_type': "refresh_token",
'redirect_uri': 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=headers)
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'),
'onedrive_token_validity': 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 get_onedrive_tokens(self, authorize_code):
"""
Generate onedrive tokens from authorization code
"""
headers = {"content-type": "application/x-www-form-urlencoded"}
base_url = request.env['ir.config_parameter'].get_param('web.base.url')
data = {
'code': authorize_code,
'client_id': self.onedrive_client_id,
'client_secret': self.onedrive_client_secret,
'grant_type': 'authorization_code',
'scope': ONEDRIVE_SCOPE,
'redirect_uri': base_url + '/onedrive/authentication'
}
try:
res = requests.post("https://login.microsoftonline.com/common/oauth2/v2.0/token", data=data, headers=headers)
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'),
'onedrive_token_validity': 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 get_dropbox_auth_url(self):
"""
Return dropbox authorization url
@ -330,3 +440,33 @@ class AutoDatabaseBackup(models.Model):
_logger.info('Dropbox Exception: %s', error)
if rec.notify_user:
mail_template_failed.send_mail(rec.id, force_send=True)
# Onedrive Backup
elif rec.backup_destination == 'onedrive':
if rec.onedrive_token_validity <= fields.Datetime.now():
rec.generate_onedrive_refresh_token()
temp = tempfile.NamedTemporaryFile(suffix='.%s' % rec.backup_format)
with open(temp.name, "wb+") as tmp:
odoo.service.db.dump_db(rec.db_name, tmp, rec.backup_format)
headers = {'Authorization': 'Bearer %s' % rec.onedrive_access_token, 'Content-Type': 'application/json'}
upload_session_url = MICROSOFT_GRAPH_END_POINT + "/v1.0/me/drive/items/%s:/%s:/createUploadSession" % (rec.onedrive_folder_id, backup_filename)
try:
upload_session = requests.post(upload_session_url, headers=headers)
upload_url = upload_session.json().get('uploadUrl')
requests.put(upload_url, data=temp.read())
if rec.auto_remove:
list_url = MICROSOFT_GRAPH_END_POINT + "/v1.0/me/drive/items/%s/children" % rec.onedrive_folder_id
response = requests.get(list_url, headers=headers)
files = response.json().get('value')
for file in files:
create_time = file['createdDateTime'][:19].replace('T', ' ')
diff_days = (datetime.datetime.now() - datetime.datetime.strptime(create_time, '%Y-%m-%d %H:%M:%S')).days
if diff_days >= rec.days_to_remove:
delete_url = MICROSOFT_GRAPH_END_POINT + "/v1.0/me/drive/items/%s" % file['id']
requests.delete(delete_url, headers=headers)
if rec.notify_user:
mail_template_success.send_mail(rec.id, force_send=True)
except Exception as error:
rec.generated_exception = error
_logger.info('Onedrive Exception: %s', error)
if rec.notify_user:
mail_template_failed.send_mail(rec.id, force_send=True)

BIN
auto_database_backup/static/description/assets/icons/onedrive.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

BIN
auto_database_backup/static/description/assets/screenshots/dropbox1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

BIN
auto_database_backup/static/description/assets/screenshots/dropbox2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

BIN
auto_database_backup/static/description/assets/screenshots/dropbox3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

BIN
auto_database_backup/static/description/assets/screenshots/dropbox4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

BIN
auto_database_backup/static/description/assets/screenshots/onedrive1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

BIN
auto_database_backup/static/description/assets/screenshots/onedrive2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
auto_database_backup/static/description/assets/screenshots/onedrive3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
auto_database_backup/static/description/assets/screenshots/onedrive4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
auto_database_backup/static/description/assets/screenshots/onedrive5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

BIN
auto_database_backup/static/description/assets/screenshots/onedrive6.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
auto_database_backup/static/description/assets/screenshots/onedrive7.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

BIN
auto_database_backup/static/description/assets/screenshots/onedrive8.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

BIN
auto_database_backup/static/description/assets/screenshots/onedrive9.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
auto_database_backup/static/description/banner.gif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 437 KiB

After

Width:  |  Height:  |  Size: 538 KiB

116
auto_database_backup/static/description/index.html

@ -7,7 +7,7 @@
Automatic Database Backup</h1>
<p
style="font-family: 'Montserrat', sans-serif !important; font-weight: 300 !important; color: #FFFFFF !important; font-size: 1.4rem !important; text-align: center !important;">
Automatic Database Backup To Local Server, Remote Server, Google Drive And Dropbox
Automatic Database Backup To Local Server, Remote Server, Google Drive, Onedrive And Dropbox
</p>
<img src="./assets/screenshots/hero.png" class="img-responsive" width="100%" height="auto" />
</div>
@ -91,7 +91,7 @@
<p
style="font-family: 'Roboto', sans-serif !important; font-weight: 400 !important; color: #282F33 !important; font-size: 1rem !important; line-height: 30px !important;">
This module helps to generate backups of your databases automatically on regular interval of times.
The generated backups can be stored into local storage, ftp server, sftp server or Google Drive.
The generated backups can be stored into local storage, ftp server, sftp server, dropbox, Google Drive or Onedrive.
User can enable auto remove option to automatically delete old backups.
User can enable email notification to be notified about the success and failure of the backup generation
and storage.
@ -174,6 +174,22 @@
</div>
</div>
<div class="col-md-6 pl-3 py-3 d-flex">
<div class="container shadow" style="border-radius:10px; padding:10px 0px; display: flex; align-items: center;">
<div class="col-md-3 d-flex justify-content-center align-items-center"
style="display: flex; justify-content: center !important; align-items: center !important;">
<img class="img" width="60" height="60" src="/assets/icons/onedrive.png">
</div>
<div class="col-md-9" style="padding-left:0; float:left; width:70%;">
<h3 class="mt16 mb0" style="font-family:Roboto; font-weight:500; font-size:22px">
Store Backup to Onedrive</h3>
<p class="mt8" style="font-family:Roboto; margin-bottom: 0 !important;">
Generated backup can be stored to Onedrive.
</p>
</div>
</div>
</div>
<div class="col-md-6 pl-3 py-3 d-flex">
<div class="container shadow" style="border-radius:10px; padding:10px 0px; display: flex; align-items: center;">
<div class="col-md-3 d-flex justify-content-center align-items-center"
@ -303,6 +319,102 @@
height="auto" />
</div>
<div class="col-lg-12 my-3">
<h4 class="mt-3"
style="font-family: 'Roboto', sans-serif !important; font-weight: 600 !important; color: #282F33 !important; font-size: 1.3rem !important;">
Store Backup to Dropbox</h4>
<p
style="font-family: 'Roboto', sans-serif !important; font-weight: 400 !important; color: #282F33 !important; font-size: 1rem !important;">
Select backup destination as Dropbox. Enter the App key and App secret.
you'll need to register a new app in the <a href="https://www.dropbox.com/developers/apps" target="_blank">App
Console</a>.
Select Dropbox API app and choose your app's permission (files.content.write and files.content.read permissions
required).
</p>
<p
style="font-family: 'Roboto', sans-serif !important; font-weight: 400 !important; color: #282F33 !important; font-size: 1rem !important;">
Please install dropbox library (pip install dropbox).
</p>
<img src="assets/screenshots/dropbox1.png" class="img-responsive img-thumbnail border" width="100%"
height="auto"/>
<p
style="font-family: 'Roboto', sans-serif !important; font-weight: 400 !important; color: #282F33 !important; font-size: 1rem !important;">
Setup refresh token
</p>
<img src="assets/screenshots/dropbox2.png" class="img-responsive img-thumbnail border" width="100%"
height="auto"/>
<p
style="font-family: 'Roboto', sans-serif !important; font-weight: 400 !important; color: #282F33 !important; font-size: 1rem !important;">
Get the authorization code and click confirm.
</p>
<img src="assets/screenshots/dropbox3.png" class="img-responsive img-thumbnail border" width="100%"
height="auto"/>
<p
style="font-family: 'Roboto', sans-serif !important; font-weight: 400 !important; color: #282F33 !important; font-size: 1rem !important;">
Reset the refresh token if required
</p>
<img src="assets/screenshots/dropbox4.png" class="img-responsive img-thumbnail border" width="100%"
height="auto"/>
</div>
<div class="col-lg-12 my-3">
<h4 class="mt-3"
style="font-family: 'Roboto', sans-serif !important; font-weight: 600 !important; color: #282F33 !important; font-size: 1.3rem !important;">
Store Backup to Onedrive</h4>
<p
style="font-family: 'Roboto', sans-serif !important; font-weight: 400 !important; color: #282F33 !important; font-size: 1rem !important;">
Select backup destination as onedrive. Enter the App key and App secret.
you'll need to register a new app in the <a href="https://portal.azure.com/" target="_blank">Microsoft Azure portal</a>.
While registering the app for the Redirect URI restrictions, copy your Odoo database URI followed by /onedrive/authentication. Example:.
</p>
<img src="assets/screenshots/onedrive1.png" class="img-responsive img-thumbnail border" width="100%"
height="auto"/>
<p
style="font-family: 'Roboto', sans-serif !important; font-weight: 400 !important; color: #282F33 !important; font-size: 1rem !important;">
Copy the Client ID
</p>
<img src="assets/screenshots/onedrive2.png" class="img-responsive img-thumbnail border" width="100%"
height="auto"/>
<p
style="font-family: 'Roboto', sans-serif !important; font-weight: 400 !important; color: #282F33 !important; font-size: 1rem !important;">
Generate Client Secret.
</p>
<img src="assets/screenshots/onedrive3.png" class="img-responsive img-thumbnail border" width="100%"
height="auto"/>
<img src="assets/screenshots/onedrive4.png" class="img-responsive img-thumbnail border" width="100%"
height="auto"/>
<p
style="font-family: 'Roboto', sans-serif !important; font-weight: 400 !important; color: #282F33 !important; font-size: 1rem !important;">
get onedrive folder ID, where need to store the backup files,
</p>
<img src="assets/screenshots/onedrive5.png" class="img-responsive img-thumbnail border" width="100%"
height="auto"/>
<p
style="font-family: 'Roboto', sans-serif !important; font-weight: 400 !important; color: #282F33 !important; font-size: 1rem !important;">
Configure the backup
</p>
<img src="assets/screenshots/onedrive6.png" class="img-responsive img-thumbnail border" width="100%"
height="auto"/>
<p
style="font-family: 'Roboto', sans-serif !important; font-weight: 400 !important; color: #282F33 !important; font-size: 1rem !important;">
Setu Tokens, it will be redirected to an authorization page.
</p>
<img src="assets/screenshots/onedrive7.png" class="img-responsive img-thumbnail border" width="100%"
height="auto"/>
<img src="assets/screenshots/onedrive8.png" class="img-responsive img-thumbnail border" width="100%"
height="auto"/>
<p
style="font-family: 'Roboto', sans-serif !important; font-weight: 400 !important; color: #282F33 !important; font-size: 1rem !important;">
Reset the token if required
</p>
<img src="assets/screenshots/onedrive9.png" class="img-responsive img-thumbnail border" width="100%"
height="auto"/>
</div>
<div class="col-lg-12 my-3">
<h4 class="mt-3"

25
auto_database_backup/views/db_backup_configure_views.xml

@ -52,6 +52,13 @@
<field name="google_drive_folderid" attrs="{'invisible': [('backup_destination', '!=', 'google_drive')], 'required': [('backup_destination', '=', 'google_drive')]}"/>
<field name="dropbox_client_id" string="App Key" attrs="{'invisible': [('backup_destination', '!=', 'dropbox')], 'required': [('backup_destination', '=', 'dropbox')]}" password="True"/>
<field name="dropbox_client_secret" string="App Secret" attrs="{'invisible': [('backup_destination', '!=', 'dropbox')], 'required': [('backup_destination', '=', 'dropbox')]}" password="True"/>
<field name="onedrive_client_id" string="Client ID" attrs="{'invisible': [('backup_destination', '!=', 'onedrive')], 'required': [('backup_destination', '=', 'onedrive')]}"/>
<field name="onedrive_client_secret" string="Client Secret" attrs="{'invisible': [('backup_destination', '!=', 'onedrive')], 'required': [('backup_destination', '=', 'onedrive')]}" password="True"/>
<field name="onedrive_folder_id" string="Folder ID" attrs="{'invisible': [('backup_destination', '!=', 'onedrive')], 'required': [('backup_destination', '=', 'onedrive')]}"/>
<field name="onedrive_access_token" string="Access Token" invisible="1" password="True"/>
<field name="onedrive_refresh_token" string="Refresh Token" invisible="1" password="True"/>
<field name="onedrive_token_validity" string="Token Validity" invisible="1"/>
<field name="is_onedrive_token_generated" invisible="1"/>
<div>
<div attrs="{'invisible': ['|', ('backup_destination', '!=', 'dropbox'), ('is_dropbox_token_generated', '=', False)]}">
<i class="text-success fa fa-check"></i>
@ -80,6 +87,24 @@
</button>
</div>
</div>
<div>
<div attrs="{'invisible': ['|', ('backup_destination', '!=', 'onedrive'), ('is_onedrive_token_generated', '=', True)]}">
<button class="btn btn-link"
name="action_get_onedrive_auth_code"
type="object">
<i class="fa fa-arrow-right"></i>
Setup Token
</button>
</div>
<div attrs="{'invisible': ['|', ('backup_destination', '!=', 'onedrive'), ('is_onedrive_token_generated', '=', False)]}">
<button class="btn btn-link"
name="action_get_onedrive_auth_code"
type="object">
<i class="fa fa-arrow-right"></i>
Reset Token
</button>
</div>
</div>
<field name="dropbox_refresh_token" invisible="1"/>
<field name="is_dropbox_token_generated" invisible="1"/>
<field name="dropbox_folder" attrs="{'invisible': [('backup_destination', '!=', 'dropbox')], 'required': [('backup_destination', '=', 'dropbox')]}"/>

Loading…
Cancel
Save