2

I've been struggling trying to mimic in openerp a report found in Tryton for the module Health GNU. In their report folder lies a report.odt file very similar to any sxw report found in openerp, with a few exceptions that is. For instance, instead of openERP's:

[[repeatIn(objects,'test')]]

we have an opening and closing tag of for making the previous exmaple as such:

<FOR EACH="TEST IN OBJECTS"> .... </FOR>

How can I mimic the following in a traditional sxw report:

<for each="case in test.critearea">
<if test="case.excluded==0"> #this is outside the table
...values in table... #table starts here
</if>
<for>
which basically excludes an entire row when matched.
using familiar syntax such as [[ case.excluded==False ]] didnt work.

tshepang
  • 12,111
  • 21
  • 91
  • 136
3a2roub
  • 573
  • 1
  • 7
  • 19

4 Answers4

4

tryton report system is based on relatorio lib and uses odt/ods as you discovered. if you want to use something similar you have to use Aeroo (formerly report_openoffice). It's not compatible with RML stuff.

This approach is much more sane that openerp's internal one and will boost you 'report productivity' a lot. You may also consider using report_webkit that allows you to write report in HTML.

simahawk
  • 2,421
  • 1
  • 16
  • 22
  • Thanks simahawk, im familiar with aeroo and report_webkit but we've invested much time in creating and finalizing report with openerp's internal approach and cant go through this major change with the reporting architecture at the moment. it's a hassle but after fiddling enough with the sxw and rml files, we manage to get what we wanted. – 3a2roub Dec 18 '12 at 17:15
2

in the first table cell, this worked:
[[((case.excluded == False) or removeParentNode('blockTable')) and '']][[case.name]]
although i am still interested in knowing if there's a more logical way instead of destroying the entire created blocktable, especially since i'll be trying to figure out how not to leave an empty line when removing the parent node 'blocktable'.

3a2roub
  • 573
  • 1
  • 7
  • 19
2

You can iterate on a list generated by a function defined on report's related .py file.

Just look for examples on the addons, there are plenty of them, like:

account/report/account_aged_partner_balance.rml: [[ repeatIn(get_lines(data['form']), 'partner') ]]

tshepang
  • 12,111
  • 21
  • 91
  • 136
Mario
  • 81
  • 1
  • 1
1

Since the contents of [[...]] are just python code, you could use list comprehesions to filter out things before the iteration. So instead of this:

[[repeatIn(cases,'case')]]

try this:

[[repeatIn([c for c in cases where not case.excluded], 'case'])

or you could use the builtin filter():

[[repeatIn(filter(lambda c: not c.excluded, cases), 'case'])]]
Phil Frost
  • 3,668
  • 21
  • 29