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.

1

How to troubleshoot TypeError: type() argument 1 must be string, not None ?

By
Abdullah Sofan
on 12/10/14, 1:14 PM 874 views

I keep getting an error (TypeError: type() argument 1 must be string, not None)  from this code. What is the problem?????!!

This is my code:

=============================================================

class intrac_batches_registrations(osv.osv):


    def create(self, cr, uid, vals, context=None):
        limit = vals['count_len']
        if(limit > 2):
            raise osv.except_osv(_("Warning!"), _("Batch Limit exceeded"))
        else:
            vals['count_len'] = limit
        return super(intrac_batches_registrations, self).create(cr, uid, vals, context=context)


    _name = 'intrac.batches.registrations'
    _columns = {
        'name': fields.char('Registration Number'),
        'student_name': fields.many2one('intrac.students', 'Student Name4'),
        'batch_number': fields.many2one('intrac.batches', 'Batch Number'),
        'batch_start_date' : fields.related('batch_number', 'batch_start_date', relation='intrac.batches', type='date', readonly=True, store=True, string='Packaging Type'),
        'invoice_number': fields.char('Invoice Number', size=100),
        'result': fields.char('Result2', readonly=True),
        'testj': fields.char('Test On Chnage'),
        'batch_registration_notes': fields.text('Notes'),
        'placement_session_number': fields.many2one('intrac.placement.sessions', 'Placement Session Number'),
        'count_len': fields.integer('Counter'),
    }
    
intrac_batches_registrations()

 

==========================================

 

OpenERP Server Error

Traceback (most recent call last): File "C:\Program Files (x86)\Odoo 8.0-20140928-000204\server\.\openerp\http.py", line 499, in _handle_exception File "C:\Program Files (x86)\Odoo 8.0-20140928-000204\server\.\openerp\http.py", line 516, in dispatch File "C:\Program Files (x86)\Odoo 8.0-20140928-000204\server\.\openerp\http.py", line 282, in _call_function File "C:\Program Files (x86)\Odoo 8.0-20140928-000204\server\.\openerp\service\model.py", line 113, in wrapper File "C:\Program Files (x86)\Odoo 8.0-20140928-000204\server\.\openerp\http.py", line 279, in checked_call File "C:\Program Files (x86)\Odoo 8.0-20140928-000204\server\.\openerp\http.py", line 732, in __call__ File "C:\Program Files (x86)\Odoo 8.0-20140928-000204\server\.\openerp\http.py", line 375, in response_wrap File "C:\Program Files (x86)\Odoo 8.0-20140928-000204\server\openerp\addons\web\controllers\main.py", line 948, in call_button File "C:\Program Files (x86)\Odoo 8.0-20140928-000204\server\openerp\addons\web\controllers\main.py", line 936, in _call_kw File "C:\Program Files (x86)\Odoo 8.0-20140928-000204\server\.\openerp\api.py", line 237, in wrapper File "C:\Program Files (x86)\Odoo 8.0-20140928-000204\server\openerp\addons\base\module\module.py", line 450, in button_immediate_install File "C:\Program Files (x86)\Odoo 8.0-20140928-000204\server\.\openerp\api.py", line 237, in wrapper File "C:\Program Files (x86)\Odoo 8.0-20140928-000204\server\openerp\addons\base\module\module.py", line 497, in _button_immediate_function File "C:\Program Files (x86)\Odoo 8.0-20140928-000204\server\.\openerp\modules\registry.py", line 324, in new File "C:\Program Files (x86)\Odoo 8.0-20140928-000204\server\.\openerp\modules\loading.py", line 358, in load_modules File "C:\Program Files (x86)\Odoo 8.0-20140928-000204\server\.\openerp\modules\loading.py", line 263, in load_marked_modules File "C:\Program Files (x86)\Odoo 8.0-20140928-000204\server\.\openerp\modules\loading.py", line 158, in load_module_graph File "C:\Program Files (x86)\Odoo 8.0-20140928-000204\server\.\openerp\modules\registry.py", line 147, in load File "C:\Program Files (x86)\Odoo 8.0-20140928-000204\server\.\openerp\models.py", line 654, in _build_model TypeError: type() argument 1 must be string, not None

2
Abdullah Sofan
On 12/10/14, 2:36 PM

It turns out that instead of typing four spaces before  _name = 'intrac.batches.registrations' I used a TAB...

I spent hours on this... I will leave this question here for anyone going crazy over this error.

0
Yogesh
On 2/20/15, 7:16 AM

It is when you either missed or misspelt _name or _inherit (in case you are inheriting one) attribute of class.

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: 12/10/14, 1:14 PM
Seen: 874 times
Last updated: 3/16/15, 8:10 AM