line: show image in tab 'image/pdf'
This commit is contained in:
parent
3750a4b0f6
commit
a149f46dbb
3 changed files with 16 additions and 1 deletions
12
line.py
12
line.py
|
@ -48,6 +48,18 @@ class Line(metaclass=PoolMeta):
|
|||
media_id = fields.Char(string='File ID', readonly=True)
|
||||
media_mime = fields.Char(string='MIME', readonly=True)
|
||||
media_size = fields.Integer(string='File size', readonly=True)
|
||||
media_image = fields.Function(fields.Binary(string='Image', readonly=True,
|
||||
states={
|
||||
'invisible': ~Eval('media_mime', '').in_(['image/png', 'image/jpg', 'image/jpeg']),
|
||||
}, depends=['media_mime']),
|
||||
'on_change_with_media_image')
|
||||
|
||||
@fields.depends('media', 'media_mime')
|
||||
def on_change_with_media_image(self, name=True):
|
||||
""" return binary if its a image
|
||||
"""
|
||||
if (self.media_mime or '-').startswith('image/'):
|
||||
return self.media
|
||||
|
||||
@classmethod
|
||||
def _identify_file(cls, data, mime=True):
|
||||
|
|
|
@ -46,3 +46,6 @@ msgctxt "field:cashbook.line,media_size:"
|
|||
msgid "File size"
|
||||
msgstr "Dateigröße"
|
||||
|
||||
msgctxt "field:cashbook.line,media_image:"
|
||||
msgid "Image"
|
||||
msgstr "Bild"
|
||||
|
|
|
@ -13,10 +13,10 @@ full copyright notices and license terms. -->
|
|||
|
||||
<label name="media_name"/>
|
||||
<field name="media_name"/>
|
||||
|
||||
<label name="media_mime"/>
|
||||
<field name="media_mime"/>
|
||||
|
||||
<field name="media_image" readonly="1" colspan="4" widget="image" xexpand="1" yexpand="1"/>
|
||||
</page>
|
||||
|
||||
</xpath>
|
||||
|
|
Loading…
Reference in a new issue