Default value for binary field doesn't displayed in image widget
Affects | Status | Importance | Assigned to | Milestone | ||
---|---|---|---|---|---|---|
Odoo Server (MOVED TO GITHUB) | Status tracked in Trunk | |||||
5.0 |
Fix Released
|
Medium
|
Unassigned | |||
Trunk |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
I 'm trying to apply a default value (an image file) to a binary field but it doens't displayed on binary and image widget in object's view.
In particular:
1) I set the default value of binary field on the model:
class patient_curves (osv.osv):
def _get_diag(self, cr, uid, context):
content_
return content_of_image
_defaults = {
'height05': _get_diag,
}
_name = "med.patient.
_columns = {
'height05' : fields.
}
patient_curves()
2) In the view, when I'm trying to display the default content of the binary field inside a text widget
<field name="height05" widget="text"/>
I can see the content of the image (in characters)
BUT
when I'm trying to display the default content of the binary field inside a binary or image widget
<field name="height05" widget="image"/> or
<field name="height05"/>
I can't see the the image (or the file). The image of binary widgets have no content.
(Note that image is successfully displayed when it is generated inside a functional field)
Related branches
tags: | added: default image widget |
tags: |
added: defaults removed: default |
Are you encoding the file in base 64 before returning it in _get_diag?
I mean, something like:
image_buffer = cStringIO. StringIO( ) image_buffer. getvalue( ))
# .......write something into the image_buffer file-like object........
data = encodestring(
return data