The movie has 2 best friends who go to school together, one invents a machine to make fruit/vegetables really big (trying to solve world hunger I think) and the other friend then uses it on himself to become an adult.
He then goes to the school and is mistaken for a teacher/head teacher? He falls in love with the teacher he had a crush on and she falls in love with him. Eventually he gets turned back into a teenage boy – but it all ends happily when she gets turned into a teenage school girl… and I think the genius best friend turns himself into an adult.
I watched this in the early 90’s so my guess is that it was made sometime from the mid 80’s on.