Odoo Help


Programming error: can't adapt type 'intrac.students'

Abdullah Sofan
on 12/12/14, 9:52 AM 5,730 views

I am getting this error:

2014-12-12 14:44:33,032 4256 ERROR INTRAC openerp.sql_db: Programming error: can't adapt type 'intrac.students', in query INSERT INTO "intrac_attend" ("id", "attend_date", "student_name", "attend_present", "batch_number", "attend_sheet", "create_uid", "write_uid", "create_date", "write_date") VALUES(nextval('intrac_attend_id_seq'), %s, %s, %s, %s, %s, %s, %s, (now() at time zone 'UTC'), (now() at time zone 'UTC')) RETURNING id
2014-12-12 14:44:33,049 4256 ERROR INTRAC openerp.http: Exception during JSON request handling.

Can someone help me figure out the problem?


This is my code:


class intrac_att_sheet(osv.osv):

    def onchange_batch_number(self, cr, uid, ids, batch_number, attend_date, name, context=None):
        if batch_number:
            getmodelfields = self.pool.get('intrac.batches.registrations')
            for records in getmodelfields.browse(cr, uid, batch_number, context=context):
                browse_student_name = records.student_name
                attend_obj = self.pool.get('intrac.attend')
                attend_obj.create(cr, uid,{'batch_number' : batch_number, 'student_name': browse_student_name , 'attend_date':attend_date, 'attend_present': True, 'attend_sheet': name}, context=context)
        return {'value':{}}

    _name = 'intrac.att.sheet'
    _columns = {
        'batch_number': fields.many2one('intrac.batches', 'Batch_number'),
        'attend_date': fields.date('Date'),
        'attend_records':fields.one2many('intrac.attend', 'attend_sheet', 'Attendance Sheet'),


class intrac_attend(osv.osv):

    _name = 'intrac.attend'
    _columns = {
        'name':fields.char('Attendance Record Number'),
        'batch_number': fields.many2one('intrac.batches', 'Batch Number'),
        'student_name': fields.many2one('intrac.students', 'Student Name'),
        'attend_date': fields.date('Date'),
        'attend_present': fields.boolean('Present'),
        'attend_remarks': fields.char('Remarks'),
        'attend_sheet':fields.many2one('intrac.att.sheet', 'Attendance Sheet'),



class intrac_batches_registrations(osv.osv):

    _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.date('Start Date'),
        'invoice_number': fields.char('Invoice Number', size=100),
        'result': fields.char('Result2'),
        'batch_registration_notes': fields.text('Notes'),
        'placement_session_number': fields.many2one('intrac.placement.sessions', 'Placement Session Number'),
        'count_len': fields.integer('Counter'),


class intrac_students(osv.osv):

    _name = 'intrac.students'
    _columns = {
        'name': fields.many2one('res.partner', 'Student Name'),
        'student_number': fields.char('Student Number', readonly=True),
        'student_image': fields.binary("Student Picture"),
        'student_id_type': fields.selection([('Government ID','Government ID'),('Passport','Passport')],'Identification Type'),
        'student_id_number': fields.char('ID Number', size=100),
        'student_gender': fields.selection([('Male','Male'),('Female','Female')], 'Gender'),
        'student_education_level': fields.selection([('High School','High School'),('College','College')], 'Education Level'),
        'student_notes': fields.one2many('intrac.students.notes', 'student_name', 'Student Notes'),
        'student_dob': fields.date('Date of Birth'),



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/12/14, 10:11 AM

Problem that you are passing browse object instead of simple id or char value in create method.
So instead you should try this:

browse_student_name = records.student_name.id

In your code I have seen that you are creating a record from onchange instead passing/return values in dictionary.
You should not create/write the data in onchange, it cause some issues. Instead you should pass your dicitonary from onchange like this:

return {'value': ur_val_dict}

Please refer onchange in Odoo.

It worked. thank you. I also appreciate the tip about not using on_change for creating data. I will move the code into a create method.

Abdullah Sofan
on 12/12/14, 11:54 AM

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

2 follower(s)


Asked: 12/12/14, 9:52 AM
Seen: 5730 times
Last updated: 3/16/15, 8:10 AM