这是我的代码
verbindingen.py
from openerp.osv import fields, osv
import logging
class verbindingen(osv.osv):
_name = "verbindingen.verbindingen"
_description = "De verbindingen"
_columns = {
#'customer_id' : fields.one2many('res.partner','x_customer_id','Customer ID'),
'kanaal_id' : fields.one2many('verbindingen.kanalen', 'verbinding_id'),
'aansluitadres_straat' : fields.char('Aansluitadres straat', size = 40),
'aansluitadres_huisnummer' : fields.char('Aansluitadres huisnummer', size = 6),
'aansluitadres_postcode' : fields.char('Aansluitadres postcode', size = 6),
'aansluitadres_toevoeging' : fields.char('Aansluitadres toevoeging', size = 6),
'aansluitadres_plaats' : fields.char('Aansluitadres plaats', size = 40),
'verbinding_type_id' : fields.one2many('verbindingen.types','verbinding_id','Verbinding type'),
'leveranciers_id' : fields.integer('Leveranciers ID', size = 20),
'service_id' : fields.integer('Service ID', size = 20),
'dikader' : fields.integer('Dikader'),
'management_ip' : fields.char('Management ip', size = 15),
'management_username' : fields.char('Management username', size = 20),
'management_psswd' : fields.char('Management password', size = 20),
}
kanalen.py
from openerp.osv import fields, osv
class kanalen(osv.osv):
_name = "verbindingen.kanalen"
_description = "Kanalen van de verbindingen"
_columns = {
'type_kanaal' : fields.selection([], 'Type kanaal'),
'verbinding_id' : fields.many2one('verbindingen.verbindingen'),
'VLAN_ID' : fields.integer('Vlan ID'),
'MAC' : fields.char('MAC Adress', size = 17),
'IP' : fields.char('IP-adres'),
'VCI/VPI' : fields.char('VCI/VPI'),
'status' : fields.selection([('active', 'Active'),('inactive', 'Inactive')], 'Status')
}
当我尝试安装此模块时,我收到一个KeyError:' verbinding_id'错误。 我不知道我的代码有什么问题。
答案 0 :(得分:0)
我已经根据您的代码创建了两个模型,例如verbindingen.verbindingen
和verbindingen.kanalen
,那么verbindingen.types
在哪里。?
如果不存在那么在那里创建模型verbindingen.types
和新的m2o字段或从关系字段中删除
'verbinding_type_id' : fields.one2many('verbindingen.types','verbinding_id','Verbinding type')