From f2abde5659aa087ff8834140147f8d3be3bcdb3e Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Mon, 14 Nov 2016 22:27:53 +0100 Subject: [PATCH] [FIX] base: binary url attachment on windows On windows when opening a binary file a 'b' flag is to be used: https://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files Before this commit, /web/image/* and /web/content/* routes serving an ir.attachment with url could return empty or truncated content. opw-693306 --- openerp/addons/base/ir/ir_http.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openerp/addons/base/ir/ir_http.py b/openerp/addons/base/ir/ir_http.py index dde75a64a76..2ff316f1ea1 100644 --- a/openerp/addons/base/ir/ir_http.py +++ b/openerp/addons/base/ir/ir_http.py @@ -264,7 +264,7 @@ class ir_http(osv.AbstractModel): module_path = os.path.join(os.path.normpath(module_path), '') # join ensures the path ends with '/' module_resource_path = os.path.normpath(module_resource_path) if module_resource_path.startswith(module_path): - with open(module_resource_path, 'r') as f: + with open(module_resource_path, 'rb') as f: content = base64.b64encode(f.read()) last_update = str(os.path.getmtime(module_resource_path))