2016-06-17 43 views
0

我試圖在odoo中創建一個計算模塊,但在安裝模塊後發生內部服務器錯誤,我不知道它。我剛剛學習了odoo,希望對你有所幫助。Odoo - 安裝後自定義模塊內部服務器錯誤

hit.py

from openerp import osv, fields 
class hit(osv.osv): 
_name  = 'eha.hit' 
_columns = { 
    'num1'  : fields.float('Number 1'), 
    'num2'  : fields.float('Number 2') 
} 

def on_change_price(self,cr,user,ids,num1,num2,context=None): 
#Calculate the total 
total = num1 + num2 
    res = { 
     'value': { 
    #This sets the total price on the field standard_price. 
      'standard_price': total 
     } 
} 
#Return the values to update it in the view. 
return res 

hit.xml:

<openerp> 
<data> 
    <record id="hitung_list" model="ir.ui.view"> 
     <field name="name">pajak_list</field> 
     <field name="model">eha.hit</field> 
     <field name="arch" type="xml"> 
       <xpath expr="//field[@name='standard_price']" position="before"> 
       <field name ="num1" on_change="on_change_price(num1,num2)"/> 
       <field name ="num2" on_change="on_change_price(num1,num2)" /> 
       </xpath> 
     </field> 
    </record> 
    </data> 
    </openerp> 

後,我安裝,我得到 「內部服務器odoo」

File "E:\Odoo 8.0-20160615\server\openerp\addons\pajak\__init__.py", line 2, in <module> 
import pph 
File "E:\Odoo 8.0-20160615\server\openerp\addons\pajak\pph.py", line 6 
results = {} 
     ^
IndentationError: unindent does not match any outer indentation level 
+1

[HTTP 500](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#5xx_Server_Error)你有在服務器側上的異常之前通常發生。嘗試查看日誌以獲取有關異常情況的更多信息,並將該信息添加到您的問題中。另外,請儘量避免使用圖片,您發佈的圖片可能只是文本的複製粘貼。謝謝。 – lrnzcig

+0

這是服務器端的錯誤...您必須向我們顯示從日誌或終端(如果您沒有將日誌保存到文件中)所獲得的確切錯誤消息。但是從你的'hit.xml'文件中,我可以看到你嘗試使用xpath,但是你從來沒有從任何以前的模板繼承過來.....這肯定會拋出一個錯誤,因爲沒有名爲'標準價格'的字段名稱 – danidee

回答

0

class後的模塊,它應該是內插

class hit(osv.osv):

_name  = 'eha.hit' 
+0

只是擡起頭來,它縮進了,沒有打算。 – K3v1n

+0

噢對不起@ K3v1n。 – vbt

相關問題