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

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

By
huongcute
on 7/22/14, 4:57 AM 688 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

2

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,

 

0
huongcute
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. 

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