[IMP] kanban_image uses json for id and is now tolerant to m2o id's

bzr revid: fme@openerp.com-20120809125419-j4l0063qyy6antqu
This commit is contained in:
Fabien Meghazi 2012-08-09 14:54:19 +02:00
parent e46fb9fda8
commit 528c12774d
2 changed files with 4 additions and 5 deletions

View File

@ -1373,15 +1373,13 @@ class Binary(openerpweb.Controller):
retag = hashed_session
try:
id = simplejson.loads(id)
if type(id) is list:
id = id[0] # m2o
if not id:
res = Model.default_get([field], context).get(field)
image_data = base64.b64decode(res)
else:
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))

View File

@ -757,6 +757,7 @@ instance.web_kanban.KanbanRecord = instance.web.OldWidget.extend({
} else if (this.record[field] && ! this.record[field].value) {
url = "/web/static/src/img/placeholder.png";
} else {
id = escape(JSON.stringify(id));
url = instance.connection.prefix + '/web/binary/image?session_id=' + this.session.session_id + '&model=' + model + '&field=' + field + '&id=' + id;
if (cache !== undefined) {
// Set the cache duration in seconds.