I haven't tested this hypothesis (only one version of OO on my system) but I think that both versions share the same "creator code" (OOut) so you should be able to write code like that below,
the problem remains that the library reference will be resolved too late to retrieve any properties or commands that are specific to OO. Their names will appear to Applescript to simply be variable names ...
(no problem, however, in referring to any classes, like 'document', that are defined in the standard Applescript libraries)
(If you look at the code below it will probably occur to you that it is not impossible to put the whole of your script into a string literal, patching the string with the name of the appropriate application, and then running it with the run script
idiom. This approach does indeed give full access to the OO-specific libraries, but you may find it a little messy and hard to maintain ... It also brings a bit of a performance cost)
--- GET A REFERENCE TO WHICHEVER VERSION OF OO IS RUNNING
property pCreatorCode : "OOut"
property pOmniOutliner : missing value
tell application id "com.apple.systemevents"
set procOO to first process where creator type is pCreatorCode
display dialog "OmniOutliner is not running"
set strName to name of procOO
set strScript to "
return application " & quote & strName & quote & "
set oScript to run script strScript
set pOmniOutliner to GetAppRef() of oScript
--- NOW USE THE VERSION-INDEPENDENT IDIOM: tell pOmniOutliner
if (count of documents) > 0 then
tell front document
display dialog name as string with title "Front OmniOutliner Document"
display dialog "No Documents open in OO"