Odoo Help


name_get TypeError: descriptor 'format' requires a 'str' object but received a 'bool'?

Abdullah Sofan
on 12/22/14, 4:46 PM 1,723 views

I have this code for name_get but I am getting the error: 

in name_get TypeError: descriptor 'format' requires a 'str' object but received a 'bool'

I think I am not doing the name_get function right. Can you please help?

This is the code:   


def name_get(self, cursor, uid, ids, context=None):
        res = []
        for nget in self.browse(cursor, uid, ids):
            name = [str.format(nget.name), str.format(nget.batch_course_name), str.format(nget.batch_teacher),                     str.format(nget.batch_start_date), str.format(nget.batch_start_time), str.format(nget.batch_end_time)]
            res.append((nget.id, ", ".join(name)))
        return res


_name = 'intrac.batches'
    _columns = {
        'name': fields.char('Batch Number', readonly=True),
        'batch_course_name': fields.many2one('intrac.courses', 'Course', required=True),
        'batch_course_category': fields.char('Course Category', required=True),
        'batch_start_date': fields.date('Start Date', required=True),
        'batch_end_date': fields.date('End Date', required=True),
        'batch_duration': fields.integer('Batch Duration (Hours)', required=True),
        'batch_hours_per_day': fields.integer('Hours Per Day', required=True),
        'batch_teacher': fields.many2one('intrac.teachers', 'Teacher', required=True),
        'batch_start_time': fields.selection([('07:00 AM','07:00 AM'),('08:45 PM','08:45 PM')], 'Start Time', required=True),
        'batch_end_time': fields.selection([('07:00 AM','07:00 AM'),('07:15 AM','07:15 AM')], 'End Time', required=True),
        'batch_classroom': fields.many2one('intrac.classrooms', 'Classroom', required=True),
        'classroom_capacity': fields.integer('Classroom Capacity', required=True),
        'batch_registrations': fields.one2many('intrac.batches.registrations', 'batch_number', 'Registrations'),
        'batch_att_sheets': fields.one2many('intrac.att.sheet', 'batch_number', 'Daily Attendance Sheets'),
        'batch_attendance' : fields.one2many('intrac.attend', 'batch_number', 'Batch Attendance'),
        'batch_notes': fields.one2many('intrac.batches.notes', 'batch_number', 'Notes'),


Sudhir Arya (SA)
On 12/22/14, 4:59 PM

Most of the fields which you are using in name_get are many2one fields.

So first you should check whether the many2one field does have value, if yes then append it in list like this.

for nget in self.browse(cursor, uid, ids):
    name = []
    if nget.batch_course_name:
    #if nget.your_other_fields:

On 12/23/14, 12:25 AM

The error is caused by incorrect use of format function.  You may want to check https://docs.python.org/2/library/functions.html#format.

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