This question has been flagged
5 Replies
8936 Views

Hi all

I need some help. I  have an error : AttributeError: 'NoneType' object has no attribute '_columns

I try install a module to server. Module :

fie.py

from openerp.osv import fields, osv

class danh_sach_nv(osv.osv):
    _name='danh.sach.nv'
    _inherits = ['danh.sach.hd','danh.sach.kt','danh.sach.kl']
    

    
    _columns={
              'ngay_sinh':fields.datetime('Ngày sinh'),
              'gender': fields.selection([('nam','Nam'),('nu','Nữ'),('khac','Khác')],'Giới tính'),
              'image_nv':fields.binary('Ảnh đại diện'),
              'sdt':fields.integer('Số DTDĐ'),
              'email':fields.char('Email',size = 30),
              'tai_khoan_nh':fields.char('Tài khoản ngân hàng',size = 50),
              'ten_nh':fields.char('Tên ngân hàng',size = 30),
              'the_bhxh':fields.char('Thẻ bảo hiểm xã hội',size=30),
              'so_lan_ky':fields.integer('Số lần ký'),
              'loai_hd':fields.char('Loại hợp đồng',size = 30),

 def on_change_dieu_chinh(self,cr,uid,ids,luong_ctm,context=None):
  
        if not luong_ctm:
            return{}
        else:
            res={}
            obj=self.pool.get('dieu.chinh.luong').browse(cr,uid,luong_ctm,context = None)
            res['luong_ct']=obj.luong_ctm
            res['ma_nv']=obj.ma_nvm
            res['ma_bp']=obj.ma_bpm
            res['ma_cd']=obj.ma_cdm
            res['ten_bp']=obj.ten_bpm
            res['ten_cd'] = obj.ten_cdm
            res['ten_cv']=obj.ten_cvm
            res['ma_cv']=obj.ma_cvm
            return{'value':res} 
        

class danh_sach_hop_dong_ld(osv.osv):
    _name='danh.sach.hd'
    
    
    def get_ma_hd(self,uid,cr,ids,context=None):
        md = self.pool.get('danh.sach.huy.hd')
        danh_sach_hop_dong_ids = md.search(cr,uid,[('ma_hd','like','ma_hd')],limit=None,context = None, count=False)
        self.unlink(cr,uid,danh_sach_hop_dong_ids)
        return True
  
      

    _columns={
              'stt':fields.char('STT',size = 10),
              'ma_hd':fields.char('Mã HĐ',size=20,required=True),
              'ngay_ky':fields.datetime('Ngày ký',required=True),
              'ma_nv':fields.char('Mã NV',size=30),
              'ten_nv':fields.char('Nhân viên',size = 50,required=True),
              'ten_bp':fields.many2one('bo.phan', 'Bộ phận', required=False),
              'ma_bp':fields.one2many('bo.phan','ten_bp','Mã BP',required=True),
              'ten_cd':fields.many2one('chuc.danh','Chức danh',required=True),
              'ma_cd':fields.one2many('chuc.danh','ten_cd','Mã CD',required=True),

 class danh_sach_khen_thuong(osv.osv):
    _name='danh.sach.kt'
    _columns={
              'stt':fields.char('STT',size = 10),
              'ten_bp':fields.one2many('danh.sach.nv','ma_nv','Bộ phận',required=True),
              'ma_bp':fields.one2many('danh.sach.nv','ma_nv','Mã BP',required=True),
              'ten_cd':fields.one2many('danh.sach.nv','ma_nv','Chức danh',required=True),
              'ma_cd':fields.one2many('danh.sach.nv','ma_nv','Mã CD',required=True),
              'ten_cv':fields.one2many('danh.sach.nv','ma_nv','Công Việc',required=True),

}

class danh_sach_kl(osv.osv):
    _name='danh.sach.kl'
    _columns={
              'stt':fields.char('STT',size = 10),
              'ten_bp':fields.one2many('danh.sach.nv','ma_nv','Bộ phận',required=True),
              'ma_bp':fields.one2many('danh.sach.nv','ma_nv','Mã BP',required=True),
              'ten_cd':fields.one2many('danh.sach.nv','ma_nv','Chức danh',required=True),
              'ma_cd':fields.one2many('danh.sach.nv','ma_nv','Mã CD',required=True),

}

fie .xml 

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        
        
        <record model='ir.ui.view' id='danh_sach_nv_tree'>
            <field name='name'>danh.sach.nv.tree</field>
            <field name='model'>danh.sach.nv</field>
            <field name='type'>tree</field>
            <field name='arch' type='xml'>
                <tree string = 'Danh Sách Nhân Viên'>        
                    <field name = 'stt'/>
                    <field name = 'ten_bp'/>
                    <field name = 'ma_bp'/>
                    <field name = 'ten_cd'/>
                    <field name = 'ma_cd'/>
                    <field name = 'ten_nv'/>
                    <field name = 'ma_nv'/>
                    <field name ='ngay_sinh'/>
                    <field name = 'gender'/>
                    <field name ='noi_lam_viec'/>
                        
                        
                </tree>
            </field>
        </record>
        <record model='ir.ui.view' id='danh_sach_nv_form'>
            <field name='name'>danh.sach.nv.form</field>
                <field name='model'>danh.sach.nv</field>
                <field name='type'>form</field>
                <field name='arch' type='xml'>
                    <form string = 'Danh Sách Nhân Viên'>
                        <group col = '4' colspan='2'>
                            <lable string = 'Nhân viên'/>
                            <field name ='image_nv'  widget='image' img_width='100' img_height='80'/>
                            <field name = 'ten_bp on_change = 'on_change_dieu_chinh(luong_ctm,context = None)'/>
                            <field name = 'ma_bp on_change = ' on_change_dieu_chinh(luong_ctm,context = None)'/>
                            <field name = 'ten_cd on_change = 'on_change_dieu_chinh(luong_ctm,context = None)'/>
                            <field name = 'ma_cd on_change = 'on_change_dieu_chinh(luong_ctm,context = None)'/>
                            <field name = 'ten_nv on_change = 'on_change_dieu_chinh(luong_ctm,context = None)'/>
                            <field name = 'ma_nv on_change = 'on_change_dieu_chinh(luong_ctm,context = None)'/>
                            <field name ='ngay_sinh'/>
                            <field name = 'gender'/>
                            <field name ='noi_lam_viec'/>
                            <field name = 'luong_ct' onchange_dieu_chinh(luong_ctm,context = None)/>
                            <field name = 'luong_tv'/>
                            
                        </group>
                        
                        <netbook colspan ='4'>
                            <page string = 'Thông tin chung nhân viên'>
                                <from string = ' Thông tin chung nhân viên'>
                                    <lable string = 'Thông tin'/>
                                    <field name = 'tai_khoan_nh'/>
                                    <field name = 'ten_nh'/>
                                    <field name = 'the_bhxh'/>
                                    <field name = 'loai_hd'/>
                                    <field name = 'so_lan_ky'/>
                                    <field name = 'ton_giao'/>
                                    <field name = 'scmnd'/>
                                    <field name = 'ngay_cap'/>
                                    <field name = 'noi_cap'/>
                                    <field name = 'dia_chi_tam_tru'/>
                                    <field name = 'dia_chi_thuong_tru'/>
                                </form>
                            </page>
                            <page string = 'Học vấn'>
                                <form string = 'Học vấn'>
                                    <lable string = 'Trình độ học vấn'/>
                                        <field name = 'trinh_do_hv'/>
                                        <field name = 'tot_nghiep_loai'/>
                                        <field name = 'hoc_vi'/>
                                        <field name = 'chuyen_mon'/>
                                        <field name = 'van_bang_khac'/>
                                        <field name = 'trinh_do_nn'/>
                                        <field name = 'trinh_do_mt'/>
                                    </form>
                            </page>
                            
                            <page string = 'Thông tin cá nhân'>
                                <form srtring = 'Thông tin cá nhân'>
                                    <lable string = 'Thông tin cá nhân'/>
                                        <sperator/>
                                        <lable string = 'Gia đình'/>
                                            <field name = 'bo_nv'/>
                                            <field name = 'tuoi_bo'/>
                                            <field name = 'dia_chi_bo'/>
                                            <field name = 'me_nv'/>
                                            <field name = 'tuoi_me'/>
                                            <field name = 'dia_chi_me'/>
                                        <sperator/>
                                        <lable string = 'Vợ hoặc chồng'/>
                                            <field name = 'vo_or_chong'/>
                                            <field name = 'noi_lam_vo_chong'/>
                                            <field name = 'tuoi_vo_chong'/>
                                            <field name = 'con_nv1'/>
                                            <field name = 'tuoi_con1'/>
                                            <field name = 'con_nv2'/>
                                            <field name = 'tuoi_con2'/>
                                            
                                </form>
                            </page>
                            
                        </netbook>
                    </form>
                </field>
        </record>
        
        <record model='ir.actions.act_window' id='action_tao_nhan_vien'>
            <field name='name'>Tạo danh sách nhân viên</field>
            <field name='res_model'>danh.sach.nv</field>
            <field name='view_type'>form</field>
            <field name='view_mode'>tree,form</field>
        </record>
        
        
        <menuitem
            id='menu_quan_ly_nhan_su_main'
            name='Quản lý Nhân sự'
            />
        <menuitem
            id='menu_danh_sach_nv'
            name='Danh sach'
            parent='menu_quan_ly_nhan_su_main'
            />
            
        <menuitem
            id='menu_tao_nhan_vien'
            name='Danh sách nhân viên'
            parent='menu_danh_sach_nv'
            action='action_tao_nhan_vien'
            />
    

fie __openerp__

{
    'name':'Quản Lý Nhân Sự',
    'author':'Huong_cute',
    'version':'1.0',
    'description':'Quản Lý nhân sự',
    'depends':['base',],
    'data':[
            'quan_ly_nhan_su_view.xml',
            'danh_sach_lien_quan.xml',
            'quan_ly_nhan_cu_view_sequense.xml'
            ],
    'update_xml':[
                  'quan_ly_nhan_su_view.xml',
                  'danh_sach_lien_quan.xml',
                  'quan_ly_nhan_cu_view_sequense.xml'
                  ],
    'installable': True,
    'auto_install': False,
    'application': False,
    'active': False,
            }

 

Any body help me. where I dont know this code has an error in 

 

Thaks all

Avatar
Discard

Remove all .xml files in the __openerp__.py file from 'data' and 'update_xml'. Then try to install the module. If it works reinsert the .xml files and update your module.

I try to do something you tell me. So It is errror AttributeError: 'NoneType' object has no attribute '_columns'. 

Can you help me


2014-07-23 15:52 GMT+07:00 <portaltemplate1460@mail.odoo.com>:

Remove all .xml files in the __openerp__.py file from 'data' and 'update_xml'. Then try to install the module. If it works reinsert the .xml files and update your module.

--
René Schuster Sent by Odoo Inc. using Odoo. Access your messages and documents in Odoo

Did your problem soved?

hi Rosey.
I did not fix it. Can you give support about it? I have erp log. You can see my code in

So I posted ERP LOG in this link. Can you check it to help me?I dont know I did incorrectly,
Thanks


2014-07-23 18:58 GMT+07:00 rosey <rosey74@mail.odoo.com>:

Did your problem soved?

--
rosey Sent by Odoo Inc. using Odoo. Access your messages and documents in Odoo

hi you. Can you help me??? I need your help


I have 2 class : dannh.sach.hd,  and danh.sach.huy.hd    . I want when I add : ma_hd into : danh.sach.huy.hd then  record  which has field : ma_hd same ma_hd in danh.sach.huy.hd ,in danh.sach.hd is deleted . I used method unlink.

my code py

class danh_sach_huy_hd(osv.Model):
    _name = 'danh.sach.huy.hd'
    
    _columns = {
                'stt':fields.char('STT',size = 5),
                'ma_hd':fields.many2one('danh.sach.hd','Mã hợp đồng', required = True),
                'ma_nv':fields.related('ma_hd','ma_nv', type = 'char',size = 10,string = 'Mã NV'),
                'ten_nv':fields.related('ma_hd','ten_nv', type = 'char',size = 10,string = 'Nhân viên'),
                'ly_do_huy_hd': fields.char('Lý do hủy hợp đồng', size = 30, required = True),
                'ngay_huy':fields.date('Ngày hủy hợp đồng',required = True),
                }
    _defaults = {
                 'stt':lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'danh.sach.stt'), 
                   
                 }  

class danh_sach_hd(osv.Model):
    _name = 'danh.sach.hd'
    _rec_name = 'ma_hd'
    
    def unlink(self, uid, cr, ids, context=None):
        if context is None:
            context = {}
        
        ref = self.pool.get('danh.sach.huy.hd').browse(cr, uid, 'ma_hd', context = context).ma_hd.id
        for rec in self.browse(cr, uid, ids, context = context):
            if rec.ma_hd == ref.ma_hd :
                return super(danh_sach_hd, self).unlink(cr, uid, rec.ma_hd.id, context=context)
    
    _columns = {
                
              'stt':fields.char('STT',size = 10),
              'ma_hd':fields.char('Mã HĐ',size=20,required=True),
              'ngay_ky':fields.date('Ngày ký',required=True),
              'ma_nv':fields.char('Mã NV',size=30),
              'ten_nv':fields.char('Nhân viên',size = 50,required=True),
              'ten_bp':fields.many2one('bo.phan', 'Bộ phận', required=False),
              'ma_bp':fields.related('ten_bp','ma_bp', type = 'char',size = 10, string = 'Mã BP'),
              'ten_cd':fields.many2one('chuc.danh','Chức danh',required=True),

}

 

So I worte it but it did not run as I want.




2014-07-23 20:59 GMT+07:00 Nguyen Huong <huongnguyen.tdh@gmail.com>:
hi Rosey.
I did not fix it. Can you give support about it? I have erp log. You can see my code in

So I posted ERP LOG in this link. Can you check it to help me?I dont know I did incorrectly,
Thanks


2014-07-23 18:58 GMT+07:00 rosey <rosey74@mail.odoo.com>:

Did your problem soved?

--
rosey Sent by Odoo Inc. using Odoo. Access your messages and documents in Odoo


Best Answer

Maybe you should declare the other three classes danh_sach_nv inherits from first.

Avatar
Discard
Best Answer

Hello huongcute,

Your "_inherits" syntax is wrong.

It should be a dictinary.
For example if you inherits "res.users" than

_inherits = {'res.users': 'user_id'}

and the "user_id" field should be a many2one field like:

'user_id': fields.many2one('res.users', 'User ID'),

Hope this will help you.

Thank you.

Avatar
Discard
Best Answer

Please check the dependency of the module you have created. In the openerp.py file, in the dependency list if 'danh.sach.hd','danh.sach.kt','danh.sach.kl' is not added, please add it. If this didnt solve your problem please provide the error log

Avatar
Discard
Best Answer

Please check inherits syntax also :

_inherits  = {'model_name':'many2one field'}  

_columns={
              'ngay_sinh':fields.datetime('Ngày sinh'),
              'gender': fields.selection([('nam','Nam'),('nu','Nữ'),('khac','Khác')],'Giới tính'),
              'image_nv':fields.binary('Ảnh đại diện'),
              'sdt':fields.integer('Số DTDĐ'),
              'email':fields.char('Email',size = 30),
              'tai_khoan_nh':fields.char('Tài khoản ngân hàng',size = 50),
              'ten_nh':fields.char('Tên ngân hàng',size = 30),
              'the_bhxh':fields.char('Thẻ bảo hiểm xã hội',size=30),
              'so_lan_ky':fields.integer('Số lần ký'),
              'loai_hd':fields.char('Loại hợp đồng',size = 30), 

 }  ------------------------ you forgot this ending of dictionary

 

_columns={
              'stt':fields.char('STT',size = 10),
              'ma_hd':fields.char('Mã HĐ',size=20,required=True),
              'ngay_ky':fields.datetime('Ngày ký',required=True),
              'ma_nv':fields.char('Mã NV',size=30),
              'ten_nv':fields.char('Nhân viên',size = 50,required=True),
              'ten_bp':fields.many2one('bo.phan', 'Bộ phận', required=False),
              'ma_bp':fields.one2many('bo.phan','ten_bp','Mã BP',required=True),
              'ten_cd':fields.many2one('chuc.danh','Chức danh',required=True),
              'ma_cd':fields.one2many('chuc.danh','ten_cd','Mã CD',required=True),

 }  ------------------------ you forgot this ending of dictionary

Avatar
Discard
Author Best Answer

Thaks Remya. I try to do according something you asked. But it didnt solve my problem. Error log : 

Traceback (most recent call last):
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\osv.py", line 132, in wrapper
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\osv.py", line 199, in execute
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\osv.py", line 187, in execute_cr
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\base\module\module.py", line 426, in button_immediate_install
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\base\module\module.py", line 477, in _button_immediate_function
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\pooler.py", line 39, in restart_pool
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\modules\registry.py", line 233, in new
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\modules\loading.py", line 354, in load_modules
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\modules\loading.py", line 256, in load_marked_modules
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\modules\loading.py", line 161, in load_module_graph
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\modules\registry.py", line 118, in load
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\orm.py", line 942, in create_instance
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\orm.py", line 1080, in __init__
  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'
2014-07-23 10:14:00,085 4320 ERROR HA-LINH openerp.netsvc: 'NoneType' object has no attribute '_columns'
Traceback (most recent call last):
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\netsvc.py", line 296, in dispatch_rpc
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\service\web_services.py", line 626, in dispatch
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\osv.py", line 190, in execute_kw
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\osv.py", line 132, in wrapper
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\osv.py", line 199, in execute
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\osv.py", line 187, in execute_cr
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\base\module\module.py", line 426, in button_immediate_install
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\base\module\module.py", line 477, in _button_immediate_function
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\pooler.py", line 39, in restart_pool
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\modules\registry.py", line 233, in new
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\modules\loading.py", line 354, in load_modules
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\modules\loading.py", line 256, in load_marked_modules
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\modules\loading.py", line 161, in load_module_graph
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\modules\registry.py", line 118, in load
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\orm.py", line 942, in create_instance
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\orm.py", line 1080, in __init__
  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'
2014-07-23 10:14:00,267 4320 INFO HA-LINH werkzeug: 127.0.0.1 - - [23/Jul/2014 10:14:00] "POST /web/dataset/call_button HTTP/1.1" 200 -

 

Please ! I need your help

I think inherits object in one module , Then it doesnt attendant in _inherits in __openerp__.py

Avatar
Discard
Author

I declared three classes in my module, So dont declared them in __inherit of __openerp__. I try to declared them, but the result is error. SO I dont think they are cause of this error. Anybody help me