我尝试在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>
安装模块后,我得到了#34;内部服务器odoo&#34;
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
答案 0 :(得分:0)
在class
之后,它应该是有意的
class hit(osv.osv):
_name = 'eha.hit'