Odoo Help

0

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

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

    }

0

Sudhir Arya (ERP Harbor Consulting Services)

--Sudhir Arya (ERP Harbor Consulting Services)--
11456
| 6 8 8
Ahmedabad, India
--Sudhir Arya (ERP Harbor Consulting Services)--

• Co-Founder & Co-Owner at ERP Harbor Consulting Services

• ERP Consultant / ERP Customization / TechnoFunctional Expert

• Sound knowledge in Python, Odoo (Open ERP), XML, PostgreSQL

• Domain knowledge of Sale Management, Purchase Management, Warehouse Management, Manufacturing, Multi Company Configuration & Management, HR Management, Medical Management, Construction Management, Education Management, Point of Sale, Third Party Integrations

• Positive attitude and quick Learner

• Good analytical skill, quick bug and issue tracing and find the solution

• Good knowledge and experience in payment gateway integration with Odoo

• Ready to accept new challenges

• Active Memeber On Stackoverflow 

LinkedIn

Blog

Stackoverflow

Sudhir Arya
ERP Harbor Consulting Services
skype: 
sudhir@erpharbor.com 
Sudhir Arya (ERP Harbor Consulting Services)
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:
        name.append(nget.batch_course_name.name)
    #if nget.your_other_fields:
        #name.append(nget.your_other_fields)

0

Ivan

--Ivan--

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

Register

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)

Stats

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