Odoo Help


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.


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

Abdullah Sofan
on 12/22/14, 4:46 PM 991 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)

--Sudhir Arya (SA)--
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow




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:



| 5 3 6
Jakarta, Indonesia
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.

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)


Asked: 12/22/14, 4:46 PM
Seen: 991 times
Last updated: 3/16/15, 8:10 AM