'Try to assign the moves to an existing picking that has not been
reserved yet and has the same procurement group, locations and picking
type (moves should already have them identical). Otherwise, create a new
picking to assign them to.'

@api.multi
def assign_picking(self):

    Picking = self.env['stock.picking']
    for move in self:
        recompute = False
        picking = Picking.search([('group_id', '=', move.group_id.id), ('location_id', '=', move.location_id.id), ('location_dest_id', '=', move.location_dest_id.id), ('picking_type_id', '=', move.picking_type_id.id), ('printed', '=', False), ('state', 'in', ['draft', 'confirmed', 'waiting', 'partially_available', 'assigned'])], limit=1)
        if (not picking):
            recompute = True
            picking = Picking.create(move._get_new_picking_values())
        move.write({'picking_id': picking.id})
        if recompute:
            move.recompute()
    return True
