Skip to Content
Menu
This question has been flagged
1 Reply
5573 Views

In OpenOffice Writer, how is it possible to remove a blockTable when a loop filter is empty.

In my sales quotation report, I have the following loop code that is meant to return all sale order lines that contain the word "sample":

repeatIn(filter(lambda x: "sample" in x.product_id.categ_id.complete_name,so.order_line),'o')

This works fine and with the addition of a formula o.name, it prints out all the requested lines.

I have put this code within a single table cell.

It works for as long as the condition is true, but if I have a sale order with absolutely no sample in any of the lines, then I get an error message saying the table cannot be empty.

So how is it possible to remove that table altogether, using the removeParentNode("blockTable") somewhere?

Avatar
Discard
Author

I actually over read Andreas' first solution. The logic works and it removes the blockTable when no order lines contain the word "sample".

But it prints the following out in the table that needs to be shown: [browse_record(sale.order.line, 96)]

I have tried to put an And '' before the or, but the table disappears again altogether, "sample" found or not.

Author

For some unknown to me reason, on my windows install I must generate the rml from OpenOfficeWriter and then send the report to the server (using the Ooo Writer functionality). Otherwise OpenERP points to the previous version of the rml file. Until I find the reason I can't edit the rml file manually. Amazingly enough, I use that rml file on my ubuntu server and I never had to send anything to the server...

You can try to use a tag/components which does not display the content. Or try to set the font color to white ...

Best Answer

Try the following line:

[[ filter(lambda x: "sample" in x.product_id.categ_id.complete_name,so.order_line) or removeParentNode("BlockTable") ]]

Update:

If you put the line right after the starting <blockTable> tag, then the "browse(.." should not be displayed. I always edit the RML manually so I do not know whether this is possible in OpenOffice.

Avatar
Discard
Author

Tried that. It gets rid of the table regardless of the content, whether an order line contains sample or not.

I am not sure whether OpenERP is case-sensitive in this case, but it should by "blockTable" and not "BlockTable". Please also check the logfiles, whether there are any errors or warnings.

Author

My code actually states "blockTable" unlike my initial message which I have just edited. I believe the interpretation is case sensitive and I do respect this in my coding.

Whats about the log file?

Author

Running my development and testing openerp on windows, I have not managed to get a log file to be generated. Production db is on Ubuntu but that's beside the point...

Author

Managed to get the log file going, but it doesn't mention anything about an error occuring, only GET and POST lines.

Related Posts Replies Views Activity
1
Mar 15
6891
5
Mar 15
19855
2
Mar 15
4895
2
Mar 15
7720
1
Mar 15
7293