[FIX] Binary image controller should not crash on virtual ids

bzr revid: fme@openerp.com-20120807105813-ybrsot6bco8ib36e
This commit is contained in:
Fabien Meghazi
2012-08-07 12:58:13 +02:00
parent 7e4d8ec0f1
commit 68d177d609
+6 -1
View File
@@ -1370,7 +1370,12 @@ class Binary(openerpweb.Controller):
res = Model.default_get([field], context).get(field)
image_data = base64.b64decode(res)
else:
res = Model.read([int(id)], [last_update, field], context)[0]
try:
id = int(id)
except (ValueError):
# objects might use virtual ids as string
pass
res = Model.read([id], [last_update, field], context)[0]
retag = hashlib.md5(res.get(last_update)).hexdigest()
image_data = base64.b64decode(res.get(field))
except (TypeError, xmlrpclib.Fault):