Is locking the cockpit door from inside is a normal procedure when one pilot leaves?
For most modern, large commercial passenger planes, there is an automatic lock, which then requires the PNF (Pilot Not Flying and outside of the cockpit) to enter an unlock code, or more usually, for the PF (Pilot Flying, and hopefully inside the cockpit) to remotely unlock the door.

The emergency access code typically sounds a cockpit warning buzzer and has a delayed operation, allowing the PF to override this in case of an unwanted, erm, "visitor", yet at the same time, allowing access to the PNF in case of PF incapacitation.

Commercially, three pilots (or two pilots and a flight engineer) on each flight are no longer economically viable for almost all airlines.  Indeed, most couldn't host a third person comfortably for the whole flight - jump seats are fine for short bursts, but not for a long-haul flight, for example.

Therefore, most airlines are now adapting their cockpit manning procedures to ensure another member of the flight crew (typically a flight attendant) joins the PF before the PNF leaves the cockpit.