lims_report_html: add operation method to allow less and greater compare

This commit is contained in:
Sebastián Marró 2020-11-01 22:42:59 -03:00
parent c275483595
commit 9e981cee80
1 changed files with 6 additions and 0 deletions

View File

@ -2,6 +2,7 @@
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
import os
import operator
from mimetypes import guess_type as mime_guess_type
from binascii import b2a_base64
from functools import partial
@ -526,6 +527,7 @@ class ResultReport(metaclass=PoolMeta):
context.update({
'report': action,
'get_image': cls.get_image,
'operation': cls.operation,
})
res = report_template.render(**context)
res = cls.parse_images(res)
@ -643,6 +645,10 @@ class ResultReport(metaclass=PoolMeta):
b64_image = b64encode(image).decode()
return 'data:image/png;base64,%s' % b64_image
@classmethod
def operation(cls, function, value1, value2):
return getattr(operator, function)(value1, value2)
@classmethod
def parse_stylesheets(cls, template_string):
Attachment = Pool().get('ir.attachment')