Skip to content

Commit

Permalink
[FIX] base: binary url attachment on windows
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nle-odoo committed Nov 14, 2016
1 parent 7be6c74 commit f2abde5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion openerp/addons/base/ir/ir_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def binary_content(self, xmlid=None, model='ir.attachment', id=None, field='data
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))

Expand Down

0 comments on commit f2abde5

Please sign in to comment.