Every company prescribes it's own policy. Door should be locked during flight unless food is served to the cockpit, or the crew has to go to the toilet etc. In case of an emergency it might be fully opened to facilitate comms with cockpit/cabin crew. Other companies might be more relaxed.