Skip to Content
Menu
This question has been flagged
2 Replies
54293 Views

In OpenERP while saving data I got this error : ProgrammingError: can't adapt type 'dict' 

I am having two tables : 

class hr_employee(osv.osv):
    _inherit = 'hr.employee'
    _name = 'hr.employee'
    _columns = {
                'emp_code':fields.char('Employee Code', size=6, readonly=True),
                'religion_id':fields.many2one('hr.religion', 'Religion'),
                'pan_id':fields.char('PAN Number', size=10),
                'marriage_date':fields.date('Marriage Date'),
                'lang_speak_ids':fields.many2many('hr.language','rel_empspeak_lang', 'employee_id','language_id', 'Languages Speak'),
                'lang_write_ids':fields.many2many('hr.language','rel_empwrite_lang', 'employee_id','language_id', 'Languages Write'),
                'education_ids':fields.one2many('hr.education.detail','employee_id', 'Courses'),
                'family_detail_ids':fields.one2many('hr.family.detail','employee_id', 'Family Details'),
                'employement_detail_ids':fields.one2many('hr.employment.detail','employee_id', 'Work Experience Information'),
                'reference_detail_ids':fields.one2many('hr.reference.detail','employee_id', 'Reference Details'),
                'training_detail_ids':fields.one2many('hr.training.detail','employee_id', 'Training Details'),
                'medical_detail_ids':fields.many2one('hr.medical.detail', 'Medical Details')                                
               }

and

 

class hr_medical_detail(osv.osv):
    
    _name = 'hr.medical.detail'
    _rec_name = 'blood_group'    
    _columns = {
                'blood_group':fields.char('Please mention your blood group:', size=100, required=True),
                'medicine':fields.boolean('Are you taking any medicine?'),               
                'physician_address':fields.text('Please mention your physician name & address:')   
                                
               }

While saving medical details getting this error.

Please, can anyone tell what could be the reason?

Avatar
Discard

I am not sure, just a thought, can it be due to the ":" in the string for "blood_group" column.

please add your xml file here ,then i can check...

Author

Thanks for your quick response guys!!! Problem was with my __openerp__.py

check your __openerp__.py file syntax

Best Answer

Hello Shiv.. I got same problem. How did u fix this?

Avatar
Discard
Best Answer

I was getting the same error but in my situation the problem happened to be that I had mistakenly used a many2one field in place of a one2many field. Looking at your code, I also see that you may have done the same thing:

'medical_detail_ids': fields.many2one('hr.medical.detail', 'Medical Details')

It appears that you meant to use a one2many field here, so it should look like this:

'medical_detail_ids': fields.one2many('hr.medical.detail', 'employee_id', 'Medical Details')

You would also need to add the following reciprocal field to hr_medical_detail:

'employee_id': fields.many2one('hr.employee', 'Employee')


The error only appeared for me when I specified a one2many widget for the field in the form view and tried to add a line item and save the form, so I suspect that you were also using a one2many widget in your form view to represent the medical_detail_ids field. Naturally, the one2many widget is not the appropriate widget to use for a many2one, and thus the cryptic error.

You say that you fixed your problem by correcting the __openerp__.py file but perhaps that was just coincidence. If you could post exactly what was wrong with your file and how you fixed it, we could determine if that was the case, and it would also help out anyone else who may have the same problem.



Avatar
Discard
Related Posts Replies Views Activity
2
Sep 23
6389
2
Mar 23
44242
0
Mar 22
1017
3
Jun 20
9165
1
Oct 19
3279