Python 完整性错误。操作无法完成,可能是由于以下原因:

Python 完整性错误。操作无法完成,可能是由于以下原因:,python,openerp,Python,Openerp,我创建了三个类,比如,id为“ali_id”的ali_khan:fields.one2many'ali.khan',chbc_id',ali khan',test_chbc和test_destitute。我在剩下的两堂课中提到了这个id。我可以在tes_chbc中添加和删除记录,但每次尝试添加记录以进行测试时,都会出现完整性错误 我的代码: 错误: 操作无法完成,可能是由于以下原因:- 删除:您可能试图删除一条记录,而其他记录 仍然引用它-创建/更新:未指定必填字段 设置正确。[引用对象:chb

我创建了三个类,比如,id为“ali_id”的ali_khan:fields.one2many'ali.khan',chbc_id',ali khan',test_chbc和test_destitute。我在剩下的两堂课中提到了这个id。我可以在tes_chbc中添加和删除记录,但每次尝试添加记录以进行测试时,都会出现完整性错误

我的代码:

错误:

操作无法完成,可能是由于以下原因:- 删除:您可能试图删除一条记录,而其他记录 仍然引用它-创建/更新:未指定必填字段 设置正确。[引用对象:chbc_id-chbc.id]

注:

如何为许多字段设置默认值,如chbc_id和destitute_id


如果未为必填字段指定值,则会发生此错误

jutt尝试升级模块,然后确保在chbc_id字段中输入有效的现有值

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',required=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'),
    }
我想您没有在chbc_id字段中拼写必填项

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',required=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'),
    }