[FIX] rml2pdf: prevent report expression evaluation from crashing report completely
This is a revert of revision 4838 revid:vmt@openerp.com-20130327160420-pxw83283xcro1h52 which was based on the idea that we ought to fix broken reports rather than hide their problems. This is correct but is blocking users even for tiny details in the report, so it is better to attempt generating the output anyway, and log an obvious error so we have all the data needed to fix the report. bzr revid: odo@openerp.com-20130627114916-d5p1qjye9tsgammj
This commit is contained in:
@@ -116,10 +116,13 @@ def _process_text(self, txt):
|
||||
result += tools.ustr(self.localcontext.get('translate', lambda x:x)(to_translate))
|
||||
if sps:
|
||||
txt = None
|
||||
expr = sps.pop(0)
|
||||
txt = eval(expr, self.localcontext)
|
||||
if txt and isinstance(txt, basestring):
|
||||
txt = tools.ustr(txt)
|
||||
try:
|
||||
expr = sps.pop(0)
|
||||
txt = eval(expr, self.localcontext)
|
||||
if txt and isinstance(txt, basestring):
|
||||
txt = tools.ustr(txt)
|
||||
except Exception:
|
||||
_logger.error("Failed to evaluate expression [[ %s ]] with context %r while rendering report, ignored.", expr, self.localcontext)
|
||||
if isinstance(txt, basestring):
|
||||
result += txt
|
||||
elif txt and (txt is not None) and (txt is not False):
|
||||
|
||||
Reference in New Issue
Block a user