summaryrefslogtreecommitdiff
path: root/addons/base_import_module
diff options
context:
space:
mode:
authorNicolas Martinelli <nim@odoo.com>2017-11-23 08:38:19 +0100
committerNicolas Martinelli <nim-odoo@users.noreply.github.com>2017-11-24 08:01:28 +0100
commitf347865161a6de20e5c42d0dca97e8571822f17f (patch)
treecf86a096bca6d292b6c2d452fe6e789beb973713 /addons/base_import_module
parentb2f6814160baf09ead2a82502f301268b8466b39 (diff)
[FIX] base_import_module: decoding error
In P3, `url_path` is already decoded in UTF-8, and therefore cannot be decoded. opw-783978 Closes #20912
Diffstat (limited to 'addons/base_import_module')
-rw-r--r--addons/base_import_module/models/ir_module.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/addons/base_import_module/models/ir_module.py b/addons/base_import_module/models/ir_module.py
index 33cd83cf1c6..aaa1e69946a 100644
--- a/addons/base_import_module/models/ir_module.py
+++ b/addons/base_import_module/models/ir_module.py
@@ -11,7 +11,7 @@ from os.path import join as opj
from odoo import api, fields, models, _
from odoo.exceptions import UserError
from odoo.modules import load_information_from_description_file
-from odoo.tools import convert_file, exception_to_unicode
+from odoo.tools import convert_file, exception_to_unicode, pycompat
from odoo.tools.osutil import tempdir
_logger = logging.getLogger(__name__)
@@ -78,8 +78,9 @@ class IrModule(models.Model):
full_path = opj(root, static_file)
with open(full_path, 'rb') as fp:
data = base64.b64encode(fp.read())
- url_path = '/%s%s' % (module, full_path.split(path)[1].replace(os.path.sep, '/'))
- url_path = url_path.decode(sys.getfilesystemencoding())
+ url_path = '/{}{}'.format(module, full_path.split(path)[1].replace(os.path.sep, '/'))
+ if not isinstance(url_path, pycompat.text_type):
+ url_path = url_path.decode(sys.getfilesystemencoding())
filename = os.path.split(url_path)[1]
values = dict(
name=filename,