How do they manage to open a new route? For example Dubai-Panama. Do they have to open new airways?
No. You do not need to create new airways. You stick up to the already existent waypoints or not, if the route flies through a segment of free-route airspace.
Also, the engineering department of the airline studies the route, for instance: computes the MSA (Minimum Safe Altitude) for every point, engine failure and depressurization simulations are done in order to avoid possible hazards in critical points, if the aircraft is ETOPS certified they will decide which alternative airports are available for the route, fuel computations, chart generation for arrival and departure (most of the airlines use their own charts instead of those provided by the ANSP), et cetera.
Each airline has its own policy and the process may vary but fundamentally the procedure done is to make a study of all the parameters that can affect to guarantee safety and efficiency.
In addition to Airman01's answer, opening a route goes beyond flying from point A to point B, you also need to:
get landing and departure slots at each of the airports. At some with lots of spare capacity, this is easy. At others, such as the largest and busiest airports, this is very difficult, and is a process that can sometimes take years. Airlines have been known to buy competitors just to get their slots.
arrange ground handling (jetways or stairs, loading/unloading luggage, refuelling, possibly catering and light maintenance, check-in and gate personnel). Sometimes this may be provided by the airport itself, sometimes it will be outsourced to specialised companies doing so in many places, sometimes to local companies, and other times it will be handled by the airline itself.
have all the relevant licenses/authorizations from countries overflown as well as source and destination, and arrange for the payment of relevant taxes and fees to the appropriate authorities.
and then you need to insert this into the rotation of the planes and crews in order to minimise downtime while still trying to find the most convenient times for your customers.
I forgot to mention that in the case of international flights, there's the issue of the Freedoms of the Air. Overflying, stopping, flying to, from or between countries other than your own is not automatic, and is usually subject to state-level agreements.
Overflying another country (First Freedom) is nearly universal (though the two states must either both be signatories of the IASTA, or have a bilateral agreement). The Wikipedia page on the topic also lists examples of flyover fees.
Further freedoms are a much more complex issue, though relatively recent changes like the EU–US Open Skies Agreement changed things a lot on many of the most competitive (and restricted) routes.
Maybe this is an exception which proves the rule, or maybe this is not exactly a valid answer because it doesn't relate to the design a new complete route, but sometimes new airway segments are created, e.g. this discussion between IATA and FAA for opening two new polar segments:
Summary of Discussions of the Sixteenth Meeting of the Cross Polar Trans East Air Traffic Management Providers Working Group (CPWG/16) 3-6 December 2013 – Ottawa, Canada
8.1. Based on ideas and proposals from IATA member airlines, State ATM Corporation developed two new route proposals that would supplement the existing cross polar routes and provide additional flexibility. The routes presented were:
a. 7957N16858W – RODOK to join G495
b. 7457N16858W – LUTEM – OLMIN – TURAN – ASKIB
8.2. The FAA agreed to review the routes and make an effort to limit restrictions. These routes will be added to the ATS Route Catalogue.
The routes were later discussed at ICAO, but seems to be still waiting for their implementation. However in the same document other routes are adjusted in the Sea of Japan: