The best way I can explain the hermie phenomonon in cannabis.
All cannabis plants can "hermie" as they fall into the category of dioecious plants. This simply means that male and female flowers are usually on two different plants. What's interesting to note with almost all plants in this category is their ability to also produce the opposing flowers to ensure the survival of the species. At the very core of it, that is what all living organisms are hardwired for.
So this really is less of a trait and more genetic hardwiring, a common foundation for the species.
The trigger is stress and this is where the traits come in. The trait is finding the genetic expression that can tollerate the highest amount of stress and not hermie. Some genetic expressions have a low stress threshhold and hermie just by looking at them wrong, while others can withstand massive fussing.
Also it is interesting that "hermie" is actually a wrong term but so widely used that it is accepted. All your "perfect" flowers are true hermie flowers and defined as having both male and female reproductive parts on a single flowers structure. Cannabis keeps its flower structures distinctly seperate.
So back to the point... stresses can be so subtle that you as a person may never know what the stress was. Regardless, once you have identified a plant "hermies" then you can assume its a stress so yes that genetic expression may not like your indoor environment and need outdoors to feel they arent being threatened.
So the key is finding those plants that can tollerate the most everyday stresses without the survival response kicking in.
All hermies should be discarded to try and eliminate the low stress tollerance trait as it carries over and offspring and genetically even less stress tollerant thus going hermie even easier.