Debug rml 6.1

Asked by Felix Schubert

How is it possible to debug rml rendering in OpenERP 6.1? I would like to see how the generated rml looks like to find out why

<fill color="pink">[[ setTag('fill','fill',{'color': data['farben'][12 + zlr]}) ]] </fill>
or
<fill color="pink">[[ setTag('fill','fill',{'color': 'green'}) ]] </fill>

doesn't work.

Thx 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:
Felix Schubert
Solved:
Last query:
Last reply:
Revision history for this message
James Monod (james-monod) said :
#1

Hello Felix,

I think fill color attribute not supported in 6.0.

You can use diffrerent attribute like backColor, textColor etc..
You can use for this same like below:

    <paraStyle name="P17" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="CENTER" backColor="#ffffff" spaceBefore="0.0" spaceAfter="6.0"/>

Thanks

Revision history for this message
Felix Schubert (input-fescon) said :
#2

Hi James,

the problem is that I need it in an illustration tag because the Text must be rotated 90 degrees.

I will try to set it in the enclosing td tag and report whether it has worked.

Thx

Felix

Revision history for this message
Felix Schubert (input-fescon) said :
#3

Hi James,

after having a look at trml2pdf.py it seems that only blockBackground is supported by OpenERP - grrrr.

so I think I have to change the reporting framework :-(

But anyhow - do you know how to get the parsed rml file (variables filled)?

Thx

Felix

Revision history for this message
Felix Schubert (input-fescon) said :
#4

This is the block which worked perfectly in version 5:

<td>
    <illustration height="80" width="13">
   <rotate degrees="90"/>
   <setFont name="Helvetica" size="7"/>
   <fill>[[ data['farben'][11] ]]</fill>
   <rect x="-1" y="-7" width="84" height="13" fill="1" stroke="0"/>
   <fill color="black"/>
     <drawString x="0" y="-2">[[ data['produkttour'][11 + zlr] ]]</drawString>
    </illustration>
        </td>

Revision history for this message
James Monod (james-monod) said :
#5

Hello Felix,

I do not get you point "do you know how to get the parsed rml file (variables filled)?"

if you want to see the output then you can get output from following file "/home/gpa/workspace/stable-6.1/server/openerp/report/render/rml2pdf/trmlpdf.py" in function "def parseString(rml, localcontext=None, fout=None, images=None, path='.', title=None):" print rml. you will get parsed rml.

If you want to implement illustration tag in 6 then you can get more detail from version 5 report engine.

Thanks

Revision history for this message
Felix Schubert (input-fescon) said :
#6

Hi James,

nearly reached my target - BUT if I set print rml nothing is printed out - and if I try to use trml2pdf.py from command line it fires an error that it can't find safe_eval :-(

Even so I can't find a difference between 5 and 6 regarding fill color - can you give me a hint in which file I should search for the difference?

Thanks a lot for your help!!!!!!!

Felix

Revision history for this message
Felix Schubert (input-fescon) said :
#7

"if you want to see the output then you can get output from following file "/home/gpa/workspace/stable-6.1/server/openerp/report/render/rml2pdf/trmlpdf.py" in function "def parseString(rml, localcontext=None, fout=None, images=None, path='.', title=None):" print rml. you will get parsed rml."

But that doesn't print any output :-(

Revision history for this message
Naresh(OpenERP) (nch-openerp) said :
#8

Hello felix,

Debugging reports is simple in OpenERP. just you need to track 4 files.

The first one /home/nch/workspace/OpenERP2012/6.1/server/openerp/report/report_sxw.py
where your raw rml arrises. It will be sent for the preprocess at line 529 which inturn will go to the second file
/home/nch/workspace/OpenERP2012/6.1/server/openerp/report/preprocess.py where the 3 important tags "repeatIn","removeParentNode","setTag" will be replaced by internal names as "rml_loop","rml_except","rml_tag" at appropriate places. then after this operation the processed rm lwill be passed to third file /home/nch/workspace/OpenERP2012/6.1/server/openerp/report/render/rml2pdf/trml2pdf.py where at line 737 (def _flowable) all the tags will be evaluted they will be using the fourth file /home/nch/workspace/OpenERP2012/6.1/server/openerp/report/render/rml2pdf/utils.py the functions _child_get(act as an iterator for the above 3 tags replaced in your case you will have the settag in here) and _process_text(for actual DB values)

Hope this helps

Thanks,
Naresh(OpenERP)

Revision history for this message
Felix Schubert (input-fescon) said :
#9

Hello Naresh,

every post I come one step closer - your post brought me a big step ahead!

The only thing I'm still fighting is how I could either print or dump the processed rml (variables replaced by the content) before it is rendered as pdf or how I can see the content of a variable like <Element illustration at 3e410a8>

Thanks a lot for your help!

Revision history for this message
Felix Schubert (input-fescon) said :
#10

Hello Naresh,

after investigating your message again and again and reading the code up and down I've got it.

For other people searching for a solution to generate illustration backgrounds dynamically:

Open trml2pdf.py and change def_render from " 'fill': lambda node: self.canvas.setFillColor(color.get(node.get('color')))," to "'fill': self._fill,". Next add the following block somewhere above:

def _fill(self, node):
  text=self._textual(node)
  text_color = utils.xml2str(text)
  if text_color and len(text_color) > 0:
   self.canvas.setFillColor(color.get(text_color)),
  else:
   self.canvas.setFillColor(color.get(node.get('color'))),

Now you can set the color dynamically in rml using <fill>variable</fill>

Thanks a lot James and Naresh!!!

Best regards

Felix

Revision history for this message
Serpent Consulting Services (serpent-consulting-services) said :
#11

Felix,

Appreciable work.

You should propose a merge to 7.0

Thanks.