line: show image in tab 'image/pdf'
This commit is contained in:
parent
40a3f4b082
commit
336d1c74f9
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_id = fields.Char(string='File ID', readonly=True)
|
||||||
media_mime = fields.Char(string='MIME', readonly=True)
|
media_mime = fields.Char(string='MIME', readonly=True)
|
||||||
media_size = fields.Integer(string='File size', 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
|
@classmethod
|
||||||
def _identify_file(cls, data, mime=True):
|
def _identify_file(cls, data, mime=True):
|
||||||
|
|
|
@ -46,3 +46,6 @@ msgctxt "field:cashbook.line,media_size:"
|
||||||
msgid "File size"
|
msgid "File size"
|
||||||
msgstr "Dateigröße"
|
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"/>
|
<label name="media_name"/>
|
||||||
<field name="media_name"/>
|
<field name="media_name"/>
|
||||||
|
|
||||||
<label name="media_mime"/>
|
<label name="media_mime"/>
|
||||||
<field name="media_mime"/>
|
<field name="media_mime"/>
|
||||||
|
|
||||||
|
<field name="media_image" readonly="1" colspan="4" widget="image" xexpand="1" yexpand="1"/>
|
||||||
</page>
|
</page>
|
||||||
|
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|
Loading…
Reference in a new issue