Usage of setTag('para','xpre') with report designer

Asked by Pieter J. Kersten (EduSense BV)

Hi,

I'm trying to allow preformatted text in reports. The documented feature is to switch parent container tags with setTag() from 'para' to 'xpre'. However, when I do that I get either a syntax error or an exception.

Tried:
[[ setTag('para','xpre') ]] [[ variable or removeParentNode('xpre') ]] syntax error (barks on brackets in expression - somehow convert.py considers this to be one expression)
[[ setTag('para','xpre') and variable or removeParentNode('xpre') ]] exception
[[ variable or removeParentNode('xpre') ]] [[ setTag('para','xpre') ]] exception
[[ (setTag('para','xpre')) and variable or removeParentNode('xpre') ]] exception

How can I process preformatted text in OpenERP (using 6.0, but 6.1 has similar issues)

Thanks in advance

Question information

Language:
English Edit question
Status:
Solved
For:
Odoo Server (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Solved by:
Pieter J. Kersten (EduSense BV)
Solved:
Last query:
Last reply:
Revision history for this message
Naresh(OpenERP) (nch-openerp) said :
#1

Hi,

Try this [[ variable and setTag('para','xpre') ]] [[ variable ]]

Thanks,
Naresh

Revision history for this message
Pieter J. Kersten (EduSense BV) (pieterj) said :
#2

Variation on a theme :-) See the results below.

Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/openerp-server/report/render/rml2pdf/utils.py", line 90, in _child_get
    eval(n.get('rml_except'), {}, self.localcontext)
  File "/usr/local/lib/python2.6/dist-packages/openerp-server/tools/safe_eval.py", line 284, in safe_eval
    return eval(test_expr(expr,_SAFE_OPCODES, mode=mode), globals_dict, locals_dict)
  File "/usr/local/lib/python2.6/dist-packages/openerp-server/tools/safe_eval.py", line 105, in test_expr
    code_obj = compile(expr, "", mode)
  File "<string>", line 1
     '' ]] [[ note or removeParentNode('para')
        ^
 SyntaxError: invalid syntax

This is in fact a parser error from convert.py
BTW, I couldn't find a single example using this feature. The few standard documents that use xpre are XSLT based.

Revision history for this message
Niels Huylebroeck (red15) said :
#3

Why not use <xpre> without the trick of using setTag ?

2012/10/18 Pieter J. Kersten (EduSense BV) <
<email address hidden>>

> Question #211560 on OpenERP Server changed:
> https://answers.launchpad.net/openobject-server/+question/211560
>
> Status: Answered => Open
>
> Pieter J. Kersten (EduSense BV) is still having a problem:
> Variation on a theme :-) See the results below.
>
> Traceback (most recent call last):
> File
> "/usr/local/lib/python2.6/dist-packages/openerp-server/report/render/rml2pdf/utils.py",
> line 90, in _child_get
> eval(n.get('rml_except'), {}, self.localcontext)
> File
> "/usr/local/lib/python2.6/dist-packages/openerp-server/tools/safe_eval.py",
> line 284, in safe_eval
> return eval(test_expr(expr,_SAFE_OPCODES, mode=mode), globals_dict,
> locals_dict)
> File
> "/usr/local/lib/python2.6/dist-packages/openerp-server/tools/safe_eval.py",
> line 105, in test_expr
> code_obj = compile(expr, "", mode)
> File "<string>", line 1
> '' ]] [[ note or removeParentNode('para')
> ^
> SyntaxError: invalid syntax
>
> This is in fact a parser error from convert.py
> BTW, I couldn't find a single example using this feature. The few standard
> documents that use xpre are XSLT based.
>
> --
> You received this question notification because you are a member of
> OpenERP Committers, which is an answer contact for OpenERP Server.
>

--
Niels Huylebroeck
Bubbles-IT
Tel. : +32 (0)9 328 33 88
Web : http://www.bubbles-it.be

Revision history for this message
Pieter J. Kersten (EduSense BV) (pieterj) said :
#4

Hi Niels,

I would be happy to do that, if I knew how. Embedding <xpre> tags directly in sxw files simply print '<xpre>'. The same applies to all other possible tags btw.

Can you tell me how I can do this?

TIA.

Revision history for this message
Pieter J. Kersten (EduSense BV) (pieterj) said :
#5

It turned out to be a combination of a bug and a missing *advertised* feature: the rml_tag code returns an invalid string and the str2xml() code embedded deeply in rml2pdf/utils.py prevents tags from variables to be interpreted.

I've created a small patch for server 6.0, fixing both issues. Porting to other versions should be trivial. If anyone is interested, contact me.