Okay, after a bit of experementation, this appears to work, with the caveat that you need to select something in the sidebar manually before running it. Hope this helps!
Code:
activate application "OmniFocus"
tell application "System Events"
tell process "OmniFocus"
--select all
keystroke "a" using {command down}
-- expand all
tell menu item 1 of menu of menu item 15 of menu 4 of menu bar 1
click
end tell
end tell
end tell