[IMP] binary/image controller uses json for id parameter
bzr revid: fme@openerp.com-20120809145918-f66m3sy9v2ybkk11
This commit is contained in:
commit
33c2df8826
|
@ -1373,15 +1373,13 @@ class Binary(openerpweb.Controller):
|
|||
|
||||
retag = hashed_session
|
||||
try:
|
||||
id = None if not id else 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))
|
||||
|
|
|
@ -4616,8 +4616,9 @@ instance.web.form.FieldBinaryImage = instance.web.form.FieldBinary.extend({
|
|||
if (this.get('value') && ! /^\d+(\.\d*)? \w+$/.test(this.get('value'))) {
|
||||
url = 'data:image/png;base64,' + this.get('value');
|
||||
} else if (this.get('value')) {
|
||||
var id = escape(JSON.stringify(this.view.datarecord.id || null));
|
||||
url = '/web/binary/image?session_id=' + this.session.session_id + '&model=' +
|
||||
this.view.dataset.model +'&id=' + (this.view.datarecord.id || '') + '&field=' + this.name + '&t=' + (new Date().getTime());
|
||||
this.view.dataset.model +'&id=' + id + '&field=' + this.name + '&t=' + (new Date().getTime());
|
||||
} else {
|
||||
url = "/web/static/src/img/placeholder.png";
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue