2016-02-13 58 views
0

我不知道爲什麼它不識別我在python文件中創建的字段。我正在將錯誤描述爲QWebException:「amt_inv」,同時評估 「line ['amt_inv']」當在odoo報告中評估時Qweb異常

這是我的Python文件,

class account_move_line(models.Model): 
    _inherit = "account.move.line" 

    amt_inv=fields.Char('Invoice') 
    amt_reinv=fields.Char('Refunded Invoice') 

這是我的xml文件的一小部分,

<tr t-foreach="lines(partner)" t-as="line"> 
    <td> 
     <t t-if="line['credit']==0"> 
      <span t-esc="line['amt_inv']"/></t>     
     <t t-if="line['credit']>0"> 
      <span t-esc="line['amt_reinv']"/></t>                           
    </td> 

回答

0
你的情況你的函數

基本上行(合作伙伴)將不會正確返回值。因此,您的行函數實例不是鍵的一部分,因此您正面臨該問題。

首先,更重要的是,您必須檢查從lines()函數返回的正確邏輯。

例如:

我已經聽到了什麼其實你是從字典返回,提到我們是如何遍歷使用我們Qweb查看文件的循環。

def lines(o.partner_id): 

    Your logic mentioned over hear for make a new the dictionary 
    res={ 
     'amt_inv':2022, 
     'amt-reinv':5244.20, 
     'credit':0, 
    } 
    return list(res) 

<tr t-foreach="lines(partner)" t-as="line"> 
    <td> 
     <t t-if="line['credit']==0"> 
      <span t-esc="line['amt_inv']"/></t>     
     <t t-if="line['credit']>0"> 
      <span t-esc="line['amt_reinv']"/></t>                           
    </td> 

聽到您可以訪問如行實例形成價值爲amt_inv密鑰的密鑰。

請嘗試再次檢查您的線功能邏輯它將返回字典的正確列表或不

我希望我的回答可能是你的:)

有幫助