Hi all. I have my code.But when I creat one row, the measege bos display error :Integrity Error
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: noi_lam_viec - noi.lam.viec]
My code. py
T
class danh_sach_nv(osv.Model):
_name = 'danh.sach.nv'
def _ma_hd(self, cr, uid , ids, arg, context):
res = {}
md = self.pool.get('danh.sach.hd').browse(cr, uid, ids, context = None)
rec = self.browse(cr, uid, ids, context = None).ma_hd
if md.ma_hd == rec.ma_hd :
res['ma_nv']=md.ma_nv
res['ten_nv']= md.ten_nv
res['ma_bp']= md.ma_bp
res['ten_cd']=md.ten_cd
res['ma_cd']= md.ma_cd
res['ten_cv']= md.ten_cv
return res
_columns={
'ma_hd':fields.many2one('danh.sach.hd','Mã HD', required = True),
'ten_bp':fields.function(_ma_hd,string='Trên đại học',type='char',size= 30,),
'ma_bp':fields.function(_ma_hd,string='Trên đại học',type='char',size= 30, ),
'ten_cd':fields.function(_ma_hd,string='Trên đại học',type='char',size= 30, ),
'ma_cd':fields.function(_ma_hd,string='Trên đại học',type='char',size= 30,),
'ten_nv':fields.function(_ma_hd,string='Trên đại học',type='char',size= 30,),
'ma_nv':fields.function(_ma_hd,string='Trên đại học',type='char',size= 30, ),
'ten_cv':fields.function(_ma_hd,string='Trên đại học',type='char',size= 30, ),
}
I need some help?Can anybody help me?