Odoo Help


I dont know why does it error??

on 7/31/14, 12:17 AM 343 views

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


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['ten_nv']= md.ten_nv
            res['ma_bp']= md.ma_bp
            res['ma_cd']= md.ma_cd
            res['ten_cv']= md.ten_cv
        return res
              '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?

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 7/31/14, 12:17 AM
Seen: 343 times
Last updated: 3/16/15, 8:10 AM