Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to avoid showing a list without elements in a RML report?

rml
By
Juan Formoso
on 6/19/14, 12:08 PM 802 views

I am trying to print a RML report in the 7.0 version. The report shows a list of elements (when their properties x and y are 0.0) in a table, each one in a different row. It works well, except for one case: when the list is empty, it gives an error. So I am racking my brains to know how to control that condition, I am a newbie in this and I cannot understand why the next lines are not working:

<blockTable  style="my_style">

    <tr>

        [[repeatIn(report.line_ids, 'line')]]

        [[line and (line.x==0.0 and line.y==0.0 and removeParentNode('tr')) or removeParentNode('blockTable')]]

        <td> ... </td>

    </tr>

</blockTable>

Please any answer or reference to a tutorial of dynamic RML reports (like this, but unfortunately, this one was not enough: https://doc.openerp.com/v6.0/developer/3_11_reports/11_1_openoffice_report.html/#dynamic-content-in-openoffice-reports) or something similar will be appreciated a lot. Thank you in advance!

EDIT

Thank you Leonardo! I tried both solutions but the error is still there. My table was divided in five columns, so I have to write not only an empty <tr></tr> but five <td></td> too! But now it works!!

0

Leonardo Donelli

--Leonardo Donelli--
1040
| 5 4 8
Cave, Italy
--Leonardo Donelli--

Physics student and part-time developer.

Leonardo Donelli
On 6/19/14, 12:14 PM

I found myself with the same problem and, as far as I recall, it was due to the fact that you can't have a <blockTable> without <tr> inside, which is what happens if the list is empty.

I solved the problem by putting a "fake" empty first line (<tr><para>  </para></tr>) so that there is at least always one line , but I think you could try, as a better solution, to change your repeatIn line with this one:

[[report.line_ids and repeatIn(report.line_ids, 'line') or removeParentNode('blockTable')]]

 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 6/19/14, 12:08 PM
Seen: 802 times
Last updated: 3/16/15, 8:10 AM