I want to display dynamically a list of values on a field, so I choosed a functionnal field, type = selection, like this :
'Numeros_bl': fields.function(_get_selection, string ='Numeros Bls', type = 'selection'),
The function is like this :
def _get_selection(self, cr, uid, ids, Numeros_bl, arg, context = None):
default = {
'value': {'Numeros_bl': {} }
}
DO = self.pool.get('stock.picking.out')
rec = self.browse(cr, uid, ids[0])
partner_id = rec.partner_id
do2pay_ids = DO.search(cr, uid, [('partner_id','=',partner_id),('state','=','done'),('invoice_state','=','2binvoiced')])
for do2pay in do2pay_ids :
do_rec= DO.browse(cr, uid, do2pay)
rs = {
'Numeros_bl': do_rec.num_bl,
}
default = default.append(rs)
return default
The problem is that this function return nothing, and I don't have any server errors, so maybe it return an empty return.
I know there is something wrong maybe with : default = {
'value': {'Numeros_bl': {} }
}
or : rs = {
'Numeros_bl': do_rec.num_bl,
}
default = default.append(rs)
or the return type, because the the function should return a selection type, because I made type = selection on the decalaration of the field, can you please tell me where I did it wrong ?