0
def _blank_line(self,nlines):
 res = ""
 for i in range(nlines - self.line_no):
     res = res + '\n'
     return res 
def _line_no(self):
   self.line_no = self.line_no + 1
   return self.line_no

这是我的 orper.py 现在......在我的 RML 代码中:

      <para style="terp_default_8">[[ repeatIn(o.order_line,'line') ]][[ line_no() ]][[ line.name or ' ' ]] </para>
    <blockTable colWidths="20.0,100.0,150.0,80.0,50.0,20.0,60.0,50.0" style="Table_Order_Pur_line_Content">
      <tr>
        <para style="terp_default_8"><font color="white">[[ blank_line(10) ]][[ setTag('para','xpre') ]]</font></para>
      <td>

我无法生成报告。什么是错误。

    3-12-09 17:24:46,257 5716 INFO Test_Dec werkzeug: 127.0.0.1 - - [09/Dec/2013 17:24:46] "POST /web/dataset/call_kw HTTP/1.1" 200 -
2013-12-09 17:24:46,276 5716 INFO Test_Dec werkzeug: 127.0.0.1 - - [09/Dec/2013 17:24:46] "POST /web/dataset/call_kw HTTP/1.1" 200 -
2013-12-09 17:24:47,828 5716 INFO Test_Dec werkzeug: 127.0.0.1 - - [09/Dec/2013 17:24:47] "POST /web/action/load HTTP/1.1" 200 -
2013-12-09 17:24:48,104 5716 ERROR Test_Dec openerp.tools.safe_eval: Cannot eval 'line_no()'
Traceback (most recent call last):
  File "C:\Program Files\OpenERP 7.0-20131021-123225\Server\server\.\openerp\tools\safe_eval.py", line 241, in safe_eval
  File "", line 1, in <module>
  File "C:\Program Files\OpenERP 7.0-20131021-123225\Server\server\openerp\addons\purchase\report\order.py", line 38, in _line_no
TypeError: range() integer end argument expected, got order.
2013-12-09 17:24:48,104 5716 ERROR Test_Dec openerp.tools.safe_eval: Cannot eval "blank_line(10)]][[ setTag('para','xpre')"
Traceback (most recent call last):
  File "C:\Program Files\OpenERP 7.0-20131021-123225\Server\server\.\openerp\tools\safe_eval.py", line 241, in safe_eval
  File "C:\Program Files\OpenERP 7.0-20131021-123225\Server\server\.\openerp\tools\safe_eval.py", line 107, in test_expr
  File "<string>", line 1
     blank_line(10)]][[ setTag('para','xpre')
                   ^
 SyntaxError: invalid syntax
2013-12-09 17:24:48,104 5716 WARNING Test_Dec openerp.report.render.rml2pdf.utils: rml_tag: "blank_line(10)]][[ setTag('para','xpre')"
Traceback (most recent call last):
  File "C:\Program Files\OpenERP 7.0-20131021-123225\Server\server\.\openerp\report\render\rml2pdf\utils.py", line 84, in _child_get
  File "C:\Program Files\OpenERP 7.0-20131021-123225\Server\server\.\openerp\tools\safe_eval.py", line 241, in safe_eval
  File "C:\Program Files\OpenERP 7.0-20131021-123225\Server\server\.\openerp\tools\safe_eval.py", line 107, in test_expr
  File "<string>", line 1
     blank_line(10)]][[ setTag('para','xpre')
                   ^
 SyntaxError: invalid syntax
4

2 回答 2

0

要访问 RML 文件中的 *line_no()* 和 *blank_line()*,您需要在解析器类的localcontext字典中声明它们。在你的order.py的 __init__() 方法中,你应该有类似的东西

    self.localcontext.update( {
        'line_no': self._line_no,
        'blank_line': self._blank_line,
        ....
    })

你有吗?

于 2013-12-09T21:49:41.750 回答
0

此问题是否已解决或仍处于打开状态。我也面临同样的问题,并在 .xml 文件中发现了问题

报告 id="report_appointment_letter" model="hr.contract" name="appointment.report" string="Appointment Letter" rml="addons/hr_contract_report/report/appointment_report.rml"

xml 中的 name 参数应与您报告解析器类中的 name 参数相同:

约会报告(report_sxw.rml_parse):

def __init__(self, cr, uid, name, context):
    if context is None:
        context = {}
    super(appointment_report, self).__init__(cr, uid, name, context=context)
    self.localcontext.update({
        'show_date': self._show_date,
        'time': time,

    })
    self.context = context

如果此问题仍然存在,希望这对其他人有所帮助

于 2014-05-23T08:21:17.027 回答