As describe in https://doc.odoo.com/6.0/developer/2_5_Objects_Fields_Methods/field_type/#relational-types
I have created a many2one field with custom selection function :
def _get_partner_sup(self, cr, uid, context=None): obj = self.pool.get('res.partner') ids = obj.search(cr, uid, [('supplier','=',True), ('is_company','=',True)]) res = obj.read(cr, uid, ids, ['name', 'id','email'], context) res = [(r['id'], r['name']) for r in res] return res _columns = { 'partner_sup_id': fields.many2one('res.partner', 'Select Supplier 2 ', selection=_get_partner_sup), } |
But it's still like a normal many2one field. What is wrong ?
And I don't want use widget='selection' or domain=[('supplier','=',True), ('is_company','=',True)]
Thanks in Advance