summaryrefslogtreecommitdiff
path: root/addons/web
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-01-12 18:15:23 +0100
committerChristophe Simonis <chs@odoo.com>2018-01-12 18:15:23 +0100
commitb42b9c936b64dca72a41422e008537c34b691912 (patch)
treeac6ef00a2c090da038f5fbe97d6c30f356c76d94 /addons/web
parentd6e3463dcd75d6a19ca237cfd2236fbff3344584 (diff)
parent3b7bf3a4b8bc799e914fa3d6de79543823c13367 (diff)
[MERGE] forward port branch saas-16 up to 3b7bf3a4b8b
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 30b75684e05..b0cf820005b 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 zlib
@@ -42,6 +43,7 @@ from odoo.http import content_disposition, dispatch_rpc, request, \
serialize_exception as _serialize_exception, Response
from odoo.exceptions import AccessError, UserError
from odoo.models import check_method_name
+from odoo.service import db
_logger = logging.getLogger(__name__)
@@ -741,12 +743,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 091c6448561..af044b13b5e 100644
--- a/addons/web/static/src/js/core/utils.js
+++ b/addons/web/static/src/js/core/utils.js
@@ -148,7 +148,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