我创建了三个类,比如,ali戋khan和一个id('ali戋ids':fields.one2many('ali.khan','chbc戋id','ali khan')、test戋chbc和test戋destitute。我在剩下的两堂课上提到了那个身份证。我可以向tes_chbc添加和删除记录,但每次尝试添加记录以进行测试时,都会出现完整性错误。。
我的代码:
class test_chbc(osv.osv):
_name="test.chbc"
_columns={
'ali_ids':fields.one2many('ali.khan', 'chbc_id', 'Ali khan'),
'first_name':fields.char('First Name',size=64),
'family_name':fields.char('Family Name',size=64),
'no_id':fields.boolean('No ID'),
'id_num':fields.char('ID Number',size=64), #with a lable of ID Number yes/no
'sex':fields.selection(gender_lov,'Sex',size=64),
'date_o_birth':fields.date('Date of birth',size=64),
}
test_chbc()
class test_destitute(osv.osv):
_name="test.destitute"
_columns={
'ali_ids':fields.one2many('ali.khan', 'destitute_ids', 'Khan'),
'first_name':fields.char('First Name',size=64),
'family_name':fields.char('Family Name',size=64),
'id_num':fields.char('ID Number',size=64), #with a lable of ID Number yes/no
'sex':fields.selection(gender_lov,'Sex',size=64),
'date_o_birth':fields.date('Date of birth',size=64),
'formal_edu':fields.char('Formul Education',size=64),
}
test_destitute()
class ali_khan(osv.osv):
_name="ali.khan"
_description="Does any member of the household have regular paid employment"
_columns={
'destitute_ids':fields.many2one('test.destitute',reuired=True),
'chbc_id':fields.many2one('test.chbc', required=True),
'person_name':fields.char('Name of Person'),
'work_type':fields.char('Type of work'),
'income_monthly':fields.char('Monthly Income'),
'com_confirm':fields.char('Communal Confirmation'),
}
ali_khan()
错误:
The operation cannot be completed, probably due to the following: - deletion: you may be trying to delete a record while other records still reference it - creation/update: a mandatory field is not correctly set. [object with reference: chbc_id-chbc.id]
注意:
How i can set default values for many2fields , like chbc_id and destitute_ids
我想你在chbc_id字段中没有拼写“required”
如果未为必需字段指定值,则会发生此错误
judt尝试升级模块,然后确保在chbc_id字段中输入有效的现有值
相关问题 更多 >
编程相关推荐