The title says it all. Out of curiosity and because I didn't find any result when searching about that, I'm asking here if it's technically possible to sell a software to an enterprise, then months later make it open source, or you have a kind of contract that completely disallow you from doing so ?
It depends on what you are selling to the enterprises.
- You could be selling just a licence to use the program, and retain all the rights on the source code.
- You could be selling the rights to the source code.
For #1, the source code is yours and you can do what it pleases with it1. In fact many programs offer both an open-source licence (which usually forces the user to make its changes to the code publicly available) and a commercial one (which allows the user to keep the modifications of the source code for themselves).
For #2, the source code is no longer yours so it is not up to you to decide what to do with it.
1I am assuming no other agreements imposing limits on those; for example that none of your contracts to your customers have a clause forbidding you from making the code available to the public.