RML repeatIn on empty list

Asked by OpenBMS JSC

Hi,

I want to loop over a custom list generated by the custom report object, something like repeatIn(get_lists(o),'c'). The trouble is when get_lists(o) return an empty list ([]), the this generate exception in RML.

What should I do to get around this?

Many thanks.

Question information

Language:
English Edit question
Status:
Solved
For:
Odoo Addons (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Solved by:
OpenBMS JSC
Solved:
Last query:
Last reply:
Revision history for this message
OpenBMS JSC (openbmsjsc) said :
#1

I have this exception if using an empty list

[2011-08-29 12:04:07,635][demohrms] ERROR:web-services:[01]: Exception:
[2011-08-29 12:04:07,635][demohrms] ERROR:web-services:[02]: Traceback (most recent call last):
[2011-08-29 12:04:07,635][demohrms] ERROR:web-services:[03]: File "/media/newdata/Projects/openerp-6.0/server/bin/service/web_services.py", line 724, in go
[2011-08-29 12:04:07,635][demohrms] ERROR:web-services:[04]: (result, format) = obj.create(cr, uid, ids, datas, context)
[2011-08-29 12:04:07,635][demohrms] ERROR:web-services:[05]: File "/media/newdata/Projects/openerp-6.0/server/bin/report/report_sxw.py", line 421, in create
[2011-08-29 12:04:07,635][demohrms] ERROR:web-services:[06]: fnct_ret = fnct(cr, uid, ids, data, report_xml, context)
[2011-08-29 12:04:07,636][demohrms] ERROR:web-services:[07]: File "/media/newdata/Projects/openerp-6.0/server/bin/report/report_sxw.py", line 484, in create_source_pdf
[2011-08-29 12:04:07,636][demohrms] ERROR:web-services:[08]: return self.create_single_pdf(cr, uid, ids, data, report_xml, context)
[2011-08-29 12:04:07,636][demohrms] ERROR:web-services:[09]: File "/media/newdata/Projects/openerp-6.0/server/bin/report/report_sxw.py", line 506, in create_single_pdf
[2011-08-29 12:04:07,636][demohrms] ERROR:web-services:[10]: pdf = create_doc(etree.tostring(processed_rml),rml_parser.localcontext,logo,title.encode('utf8'))
[2011-08-29 12:04:07,636][demohrms] ERROR:web-services:[11]: File "/media/newdata/Projects/openerp-6.0/server/bin/report/interface.py", line 193, in create_pdf
[2011-08-29 12:04:07,636][demohrms] ERROR:web-services:[12]: obj.render()
[2011-08-29 12:04:07,636][demohrms] ERROR:web-services:[13]: File "/media/newdata/Projects/openerp-6.0/server/bin/report/render/render.py", line 63, in render
[2011-08-29 12:04:07,636][demohrms] ERROR:web-services:[14]: result = self._render()
[2011-08-29 12:04:07,637][demohrms] ERROR:web-services:[15]: File "/media/newdata/Projects/openerp-6.0/server/bin/report/render/rml.py", line 41, in _render
[2011-08-29 12:04:07,637][demohrms] ERROR:web-services:[16]: return rml2pdf.parseNode(self.rml, self.localcontext, images=self.bin_datas, path=self.path,title=self.title)
[2011-08-29 12:04:07,637][demohrms] ERROR:web-services:[17]: File "/media/newdata/Projects/openerp-6.0/server/bin/report/render/rml2pdf/trml2pdf.py", line 971, in parseNode
[2011-08-29 12:04:07,637][demohrms] ERROR:web-services:[18]: r.render(fp)
[2011-08-29 12:04:07,637][demohrms] ERROR:web-services:[19]: File "/media/newdata/Projects/openerp-6.0/server/bin/report/render/rml2pdf/trml2pdf.py", line 303, in render
[2011-08-29 12:04:07,637][demohrms] ERROR:web-services:[20]: pt_obj.render(el)
[2011-08-29 12:04:07,637][demohrms] ERROR:web-services:[21]: File "/media/newdata/Projects/openerp-6.0/server/bin/report/render/rml2pdf/trml2pdf.py", line 942, in render
[2011-08-29 12:04:07,637][demohrms] ERROR:web-services:[22]: fis += r.render(node_story)
[2011-08-29 12:04:07,637][demohrms] ERROR:web-services:[23]: File "/media/newdata/Projects/openerp-6.0/server/bin/report/render/rml2pdf/trml2pdf.py", line 861, in render
[2011-08-29 12:04:07,638][demohrms] ERROR:web-services:[24]: return process_story(node_story)
[2011-08-29 12:04:07,638][demohrms] ERROR:web-services:[25]: File "/media/newdata/Projects/openerp-6.0/server/bin/report/render/rml2pdf/trml2pdf.py", line 854, in process_story
[2011-08-29 12:04:07,638][demohrms] ERROR:web-services:[26]: flow = self._flowable(node)
[2011-08-29 12:04:07,638][demohrms] ERROR:web-services:[27]: File "/media/newdata/Projects/openerp-6.0/server/bin/report/render/rml2pdf/trml2pdf.py", line 777, in _flowable
[2011-08-29 12:04:07,638][demohrms] ERROR:web-services:[28]: return self._table(node)
[2011-08-29 12:04:07,638][demohrms] ERROR:web-services:[29]: File "/media/newdata/Projects/openerp-6.0/server/bin/report/render/rml2pdf/trml2pdf.py", line 661, in _table
[2011-08-29 12:04:07,638][demohrms] ERROR:web-services:[30]: fl = self._flowable(n, extra_style=paraStyle)
[2011-08-29 12:04:07,638][demohrms] ERROR:web-services:[31]: File "/media/newdata/Projects/openerp-6.0/server/bin/report/render/rml2pdf/trml2pdf.py", line 777, in _flowable
[2011-08-29 12:04:07,639][demohrms] ERROR:web-services:[32]: return self._table(node)
[2011-08-29 12:04:07,639][demohrms] ERROR:web-services:[33]: File "/media/newdata/Projects/openerp-6.0/server/bin/report/render/rml2pdf/trml2pdf.py", line 681, in _table
[2011-08-29 12:04:07,639][demohrms] ERROR:web-services:[34]: assert length == len(node.get('colWidths').split(','))
[2011-08-29 12:04:07,639][demohrms] ERROR:web-services:[35]: AssertionError
[2011-08-29 12:04:08,551][demohrms] DEBUG:web-services:netrpc: rpc-dispatching exception
Traceback (most recent call last):
  File "/media/newdata/Projects/openerp-6.0/server/bin/service/netrpc_server.py", line 70, in run
    result = self.dispatch(msg[0], msg[1], msg[2:])
  File "/media/newdata/Projects/openerp-6.0/server/bin/netsvc.py", line 499, in dispatch
    raise OpenERPDispatcherException(e, tb_s)

Revision history for this message
OpenBMS JSC (openbmsjsc) said :
#2

I've found it myself. I'll share it here, just in case someone will run into the same problem. The idea is to wrap the test in a <para> under a <section>.

        <section>
          <para style="P10"><font color="white">[[ get_lists(o) or removeParentNode('section') ]]</font></para>
          <blockTable colWidths="141.0,122.0" style="Table9">
            <tr>
              <td>
                <para style="terp_default_9">[[repeatIn(get_lists(o),'c') ]]</para>
              </td>
...
          </blockTable>
        </section>