← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 676989] Re: specifying custom RML parent tag does not work in repeatIn

 

*** This bug is a duplicate of bug 592584 ***
    https://bugs.launchpad.net/bugs/592584

** This bug has been marked a duplicate of bug 592584
   [report] repeatIn and 3rd arg
 * You can subscribe to bug 592584 by following this link: https://bugs.launchpad.net/openobject-server/+bug/592584/+subscribe

-- 
specifying custom RML parent tag does not work in repeatIn
https://bugs.launchpad.net/bugs/676989
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.

Status in OpenObject Server: New

Bug description:
Take the following simple RML file, which uses the three-argument form of "repeatIn" statement:

<?xml version="1.0"?>
<document>
  <template>
    <pageTemplate id="first">
      <frame id="first" x1="0" y1="57.0" width="538" height="728"/>
    </pageTemplate>
  </template>
  <stylesheet>
  </stylesheet>
  <images/>
  <story>
    <blockTable>
      [[ repeatIn([1, 2, 3], 'n', 'blockTable') ]]
      <tr><td>Header #1</td>  <td>Header #2</td>  <td>Header #3</td></tr>
      <tr><td>Content #1</td>  <td>Content #2</td>  <td>Content #3</td></tr>
      <tr><td>Content #1 (2)</td>  <td>Content #2 (2)</td>  <td>Content #3 (2)</td></tr>
    </blockTable>
  </story>
</document>

I expect this to render 3 copies of a table with 3 rows and 3 columns.
Instead it throws the error:

Traceback (most recent call last):
  File "/home/david/dist/openerp-server-5.0.14/bin/service/web_services.py", line 683, in go
    (result, format) = obj.create(cr, uid, ids, datas, context)
  File "/home/david/dist/openerp-server-5.0.14/bin/report/report_sxw.py", line 365, in create
    fnct_ret = fnct(cr, uid, ids, data, report_xml, context)
  File "/home/david/dist/openerp-server-5.0.14/bin/report/report_sxw.py", line 427, in create_source_pdf
    return self.create_single_pdf(cr, uid, ids, data, report_xml, context)
  File "/home/david/dist/openerp-server-5.0.14/bin/report/report_sxw.py", line 442, in create_single_pdf
    processed_rml = self.preprocess_rml(etree.XML(rml),report_xml.report_type)
  File "/home/david/dist/openerp-server-5.0.14/bin/report/preprocess.py", line 60, in preprocess_rml
    self.preprocess_rml(node,type)
  File "/home/david/dist/openerp-server-5.0.14/bin/report/preprocess.py", line 55, in preprocess_rml
    t = _regex1.sub(_sub1, node.text or node.tail)
  File "/home/david/dist/openerp-server-5.0.14/bin/report/preprocess.py", line 51, in _sub1
    while n.tag not in match:
AttributeError: 'NoneType' object has no attribute 'tag'

Tracing the code a bit I see that the code in bin/report/preprocess.py grabs the third argument of the repeatIn statement as a plain string, taking everything after the comma as the tag to match.  Therefore if you provide a quoted string 'blockTable', it will try to match literally that tag, i.e. it will be attempting to match an RML element with a name *including* the single quotes.  Obviously no such element exists, it would be syntactically invalid.  Therefore the match attempt continues all the way up the tree until it reaches None (the root element) and gives the AttributeError above.

Attempting to use repeatIn without quoting the tag name attempts to evaluate 'blockTable' as a variable, which is obviously unbound, and an exception is raised.

I have attached a one-line patch that modifies the regex to avoid capturing the surrounding quote marks.  With the patch applied, the example RML renders correctly.  However it may not be the optimal solution and is not well tested, any comment from devs is welcome.

OpenERP server version 5.0.14 on Linux.





References