'This function returns an action that display existing picking orders of given purchase order ids.
When only one found, show the picking immediately.'

@api.multi
def action_view_picking(self):

    action = self.env.ref('stock.action_picking_tree')
    result = action.read()[0]
    result.pop('id', None)
    result['context'] = {}
    pick_ids = sum([order.picking_ids.ids for order in self], [])
    if (len(pick_ids) > 1):
        result['domain'] = (("[('id','in',[" + ','.join(map(str, pick_ids))) + '])]')
    elif (len(pick_ids) == 1):
        res = self.env.ref('stock.view_picking_form', False)
        result['views'] = [(((res and res.id) or False), 'form')]
        result['res_id'] = ((pick_ids and pick_ids[0]) or False)
    return result
