summaryrefslogtreecommitdiff
path: root/addons/web
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-01-12 17:23:10 +0100
committerChristophe Simonis <chs@odoo.com>2018-01-12 17:23:10 +0100
commit3b7bf3a4b8bc799e914fa3d6de79543823c13367 (patch)
treeb13732e56cbb2cd967e4d367aee81a9386f38555 /addons/web
parent05fe5384feea4e0b864964ae3b6b0603e982fea3 (diff)
parent8962b8ecc2a3e7215802e06eb5c76b0a88f5380f (diff)
[MERGE] forward port branch saas-15 up to 8962b8ecc2a
Diffstat (limited to 'addons/web')
-rw-r--r--addons/web/controllers/main.py9
-rw-r--r--addons/web/static/src/js/core/utils.js2
2 files changed, 8 insertions, 3 deletions
diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py
index c9da99309c6..4d58c0fab74 100644
--- a/addons/web/controllers/main.py
+++ b/addons/web/controllers/main.py
@@ -17,6 +17,7 @@ import operator
import os
import re
import sys
+import tempfile
import time
import werkzeug
import werkzeug.utils
@@ -38,6 +39,7 @@ from odoo.http import content_disposition, dispatch_rpc, request, \
serialize_exception as _serialize_exception
from odoo.exceptions import AccessError, UserError
from odoo.models import check_method_name
+from odoo.service import db
_logger = logging.getLogger(__name__)
@@ -725,12 +727,15 @@ class Database(http.Controller):
@http.route('/web/database/restore', type='http', auth="none", methods=['POST'], csrf=False)
def restore(self, master_pwd, backup_file, name, copy=False):
try:
- data = base64.b64encode(backup_file.read())
- dispatch_rpc('db', 'restore', [master_pwd, name, data, str2bool(copy)])
+ with tempfile.NamedTemporaryFile(delete=False) as data_file:
+ backup_file.save(data_file)
+ db.restore_db(name, data_file.name, str2bool(copy))
return http.local_redirect('/web/database/manager')
except Exception as e:
error = "Database restore error: %s" % (str(e) or repr(e))
return self._render_template(error=error)
+ finally:
+ os.unlink(data_file.name)
@http.route('/web/database/change_password', type='http', auth="none", methods=['POST'], csrf=False)
def change_password(self, master_pwd, master_pwd_new):
diff --git a/addons/web/static/src/js/core/utils.js b/addons/web/static/src/js/core/utils.js
index 585be4d37b8..9bba625eb4b 100644
--- a/addons/web/static/src/js/core/utils.js
+++ b/addons/web/static/src/js/core/utils.js
@@ -116,7 +116,7 @@ var utils = {
size /= 1024;
++i;
}
- return size.toFixed(2) + ' ' + units[i];
+ return size.toFixed(2) + ' ' + units[i].trim();
},
/**
* Insert "thousands" separators in the provided number (which is actually