2016-06-17 41 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

相关问题