oddo can't adapt type 'hr.employee'
<p>I want to get value of field in my class that one2many to hr_employee:</p>

<pre><code>class cashadvance(osv.osv):
    def get_employeeid(self, cr, uid, context=None):
        idemployee = ""
        employee_id = ""
        ids = self.search(cr, uid, [], context=context) # you probably want to search for all the records
        for adv in self.browse(cr, uid, ids, context=context):
            employee_id = adv.id_employee
        if (employee_id is None):
            idemployee = 0
        else:
            idemployee = employee_id
        return idemployee
    _name = 'comben.cashadvance'
    _columns = {
        'id_employee'               : fields.many2one('hr.employee', string='Employee', required=True, readonly=True),
    }
</code></pre>

<p>it raised error : can't adapt type 'hr.employee' </p>

<p>but when I changed :</p>

<pre><code>class cashadvance(osv.osv):
    def get_employeeid(self, cr, uid, context=None):
        idemployee = ""
        employee_id = ""
        ids = self.search(cr, uid, [], context=context) # you probably want to search for all the records
        for adv in self.browse(cr, uid, ids, context=context):
            employee_id = adv.id_employee
        if (employee_id is None):
            idemployee = 0
        else:
            **idemployee = 1348  #employee_id**
        return idemployee
    _name = 'comben.cashadvance'
    _columns = {
        'id_employee'               : fields.many2one('hr.employee', string='Employee', required=True, readonly=True),
    }
</code></pre>

<p>I worked fine, what I'm doing wrong with this, please help</p>

<pre><code>   for adv in self.browse(cr, uid, ids, context=context):
        employee_id = adv.id_employee
</code></pre>

<p>On this part of the code your are browsing the self model. Browse method returns a recordset, that means it returns a instance of the class that represents the model your browse runs to. If you want to get the id of any record you have to:</p>

<pre><code>        employee_id = adv.id_employee.id
</code></pre>

python openerp