Odoo Help

Welcome!

This community 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.

0

I dont know why does it error??

By
huongcute
on 7/31/14, 12:17 AM 278 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

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?

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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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