Odoo Help


Can you check a code of my module : filed. function

on 7/22/14, 4:57 AM 805 views

Hi everbody !!!

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

my code :


class tong_nhan_luc(osv.osv):
              'ten_bp':fields.one2many('danh.sach.hd','Bộ phận',required = True),
              'ma_bp':fields.one2many('bo.phan','ten_bp','Mã BP'),
              '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 !




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,


On 7/22/14, 10:53 PM

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. 

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/22/14, 4:57 AM
Seen: 805 times
Last updated: 3/16/15, 8:10 AM