From 68d177d6093e171a54b1c8e1a27bb985dc86d4eb Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 7 Aug 2012 12:58:13 +0200 Subject: [PATCH] [FIX] Binary image controller should not crash on virtual ids bzr revid: fme@openerp.com-20120807105813-ybrsot6bco8ib36e --- addons/web/controllers/main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index e4c576fecae..d24c097868b 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -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):