[FIX] correctly handle empty binary fields in saveas
Original code assumed the empty field would be missing or an empty string, b64decoding an empty string yields an other empty string which triggered a "not found" response. However Odoo returns ``False`` in case of an empty field, so that needs to be replaced by an empty string before decoding, as b64decode doesn't accept booleans as input (for some reason...)
This commit is contained in:
parent
54e75b0286
commit
3d85eaa591
|
@ -1097,7 +1097,7 @@ class Binary(http.Controller):
|
|||
res = Model.read(cr, uid, [int(id)], fields, context)[0]
|
||||
else:
|
||||
res = Model.default_get(cr, uid, fields, context)
|
||||
filecontent = base64.b64decode(res.get(field, ''))
|
||||
filecontent = base64.b64decode(res.get(field) or '')
|
||||
if not filecontent:
|
||||
return request.not_found()
|
||||
else:
|
||||
|
@ -1129,7 +1129,7 @@ class Binary(http.Controller):
|
|||
res = Model.read([int(id)], fields, context)[0]
|
||||
else:
|
||||
res = Model.default_get(fields, context)
|
||||
filecontent = base64.b64decode(res.get(field, ''))
|
||||
filecontent = base64.b64decode(res.get(field) or '')
|
||||
if not filecontent:
|
||||
raise ValueError(_("No content found for field '%s' on '%s:%s'") %
|
||||
(field, model, id))
|
||||
|
|
Loading…
Reference in New Issue