2013-12-09 53 views
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代碼:爲了」對象有沒有屬性‘_line_no’而在OpenERP的

 <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 
+0

哪條線是否定的。你的order.py中有38個? –

+0

請參閱:https://answers.launchpad.net/openobject-server/+question/211560 – Pooja

+0

我的38行是:'def __init __(self,cr,uid,name,context):' – user2860165

回答

0

要訪問* LINE_NO()*和* BLANK_LINE()*您RML文件,你需要聲明他們在localcontext字典解析器類。在您的__init __()你order.py的方法你應該有類似

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

你有嗎?

+0

是的,我也有。 – user2860165

+0

哪條線是否定的。 28在你的order.py中?我在錯誤日誌中看到以下內容,這與您發佈的代碼不符:「... ... report \ order.py」,第38行,在_line_no中 TypeError:range()整數結束參數預計,得到了訂單.--- –

0

該問題是否已得到解決,還是仍然未解決。 我也面臨着同樣的問題,發現.xml文件的問題

報告ID = 「report_appointment_letter」 模型= 「hr.contract」 NAME = 「appointment.report」字符串= 「任命書」 RML =」插件/ hr_contract_report /報告/ appointment_report.rml」

XML中的名稱參數應該是一樣的,在你的報告解析類:

appointment_report(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 

希望這會幫助別人,如果這個問題仍然存在