This question has been flagged
2 Replies
3387 Views

Hi everbody !!!

I have an error when I install module in server. NameError: name '_số_lượng_bp' is not defined. 

my code :

.py

class tong_nhan_luc(osv.osv):
    _name='tong.nhan.luc'
    _columns={
              'ten_bp':fields.one2many('danh.sach.hd','Bộ phận',required = True),
              'ma_bp':fields.one2many('bo.phan','ten_bp','Mã BP'),
              'tong_gt1':fields.integer('Nam'),
              'tong_gt2':fields.integer('Nữ'),
              'tong':fields.function(_so_luong_bp,string= 'Tổng', type = 'integer'),
              'tong_tdh':fields.function(_so_luong_tdh,string='Trên đại học',type='integer'),
              'tong_dh':fields.function(_so_luong_dh,string='Đại học',type='integer'),
              'tong_cd':fields.integer(_so_luong_cd,string='Cao đẳng',type='integer'),
              'tong_tc':fields.integer(_so_luong_tc,string='Trung cấp',type='integer'),
              'tong_c3':fields.integer(_so_luong_12,string='12/12',type = 'integer'),
              
              }
    def _so_luong_bp(self, cr, uid, ids, name, arg, context=None):
        md1 = self.pool.get('danh.sach.nv').browse()
        md2 = md1.search(cr,uid,[('ten_bp','like','ten_bp')],order='ten_bp',context=None, count=True),
        return md2
    def _so_luong_gt1(self,cr,uid,ids,context=None):
        
        md3 = self.pool.get('danh.sach.nv')
        md4 = md3.search(cr,uid,[('ten_bp','like','ten_bp'),'&',('gender','=','nam')],order='ten_bp',context=None, count=True)
        return md4
    def _so_luong_gt2(self,cr,uid,ids,context=None):
        md5 = self.pool.get('danh.sach.nv')
        md6 = md5.search(cr,uid,[('ten_bp','like','ten_bp'),'&',('gender','=','nu')],order='ten_bp',context=None, count=True)
        return md6
   
    def _so_luong_tdh(self,cr,uid,ids,context=None):
        md7 = self.pool.get('danh.sach.nv')
        md8 = md7.search(cr,uid,[('ten_bp','like','ten_bp'),'&',('trinh_do_hv','=','tdh')],order='ten_bp',context=None, count=True)
        return md8
        
    def _so_luong_dh(self,cr,uid,ids,context=None):
        md9 = self.pool.get('danh.sach.nv')
        md10 = md9.search(cr,uid,[('ten_bp','like','ten_bp'),'&',('trinh_do_hv','=','dh')],order='ten_bp',context=None, count=True)
        return md10    

 

I need any your help !

Thanks

Avatar
Discard
Best Answer

Hello,

I guess, the reason behind your code not working should be, you should write your function ( which is mentioned under field.function) above the columns, not below the columns. So please write _so_luong_bp function, abouve _columns {}.

Let me know if still there is problem. Hope this helps,

Best Regards,

 

Avatar
Discard
Author Best Answer

Thanks Hiern Vora !

I fixed it. But When I install it to server ,I have : File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\orm.py", line 3499, in _inherits_reload

AttributeError: 'NoneType' object has no attribute '_columns'.

I need your help. 

Avatar
Discard