How to hide an item on a report?

185 views Asked by At

I did some changes one of the method on accounting report in OpenERP. My problem now is how can i make some item invisible or delete? In particular, I want to hide the "Liability" and its balance on the report.

I tried something like this on get_lines method:

for report in lines:
    if report["name"].lower().replace(" ","") == 'liability':
         del report["name"]
         del report["balance"]

but when i tried to generate Balance sheet report. It says:

(<type 'exceptions.KeyError'>,KeyError('name',), <traceback object at 0x7f6c4c2903f8>)      

Any help is much appreciated.

2

There are 2 answers

2
doctore On BEST ANSWER

This is an error that raises when you try to access object key that doesn't exist. In your case "name".

Error you have is "logical" error, simply go into debug and see what you get in report variable inside loop.

Moreover, to change report content (and by report I think you mean pdf output right?) you need to override .rml file. I think you are changing report parser here, which is also ok if you know what you are doing.

Here you can find RML documentation: http://www.reportlab.com/docs/rml2pdf-userguide.pdf

So, to sum: to change report output content override or replace parser, to change structure, hide/add fields override existing report (.rml file) or create entirely new report.

Hope it helped :)

0
Anirudh Lou On

This might not be the good (or perhaps the weirdest) solution to the problem but after reading about .rml and i can't still comprehend this is what i did. Instead of trying to delete report["name"] and report["balance"] i just set it's value into a white space. This time it's no longer shown on the report.