Is there some way to prevent an opponent from receiving an attack of opportunity when you consume a potion in a threatened square?
The Drunken BrutePFD20SRD Barbarian's archetype provides the Raging Drunk class feature.
Raging Drunk (Ex)
While raging, the drunken brute can drink a potion, or a tankard of ale or similar quantity of alcohol, as a move action that does not provoke attacks of opportunity. A potion has its normal effect, while an alcoholic drink allows the barbarian to maintain her rage that round without expending a round of rage for the day (instead of the alcohol’s normal effects). For each alcoholic drink consumed while raging, the barbarian is nauseated for 1 round when her rage expires, in addition the normal fatigue that follows a rage. Tireless rage does not negate this nauseated condition but the internal fortitude rage power does.
This ability replaces fast movement.
So you can dip one level in Barbarian and rage then drink when needed. However, it comes with a steep price.
A non-core way to accomplish the same thing (but without the drawbacks of raging) is the feat Bottoms UpPFD20SRD.
You have trained yourself to swallow liquids in one quick gulp.
Prerequisite: BAB +1.
Benefit: You can drink a potion or any other small volume of liquid as a move action that does not provoke attacks of opportunity.
Note: The benefit of this feat does not include any actions needed to retrieve a potion from your inventory, only the action of consuming it.