In an XPatch, try
'[%CurrentObject%]'
instead of $O1
You could refer to the encompassing object (ie, the object of the dataview encompassing the grid, which based on your post is entity O1) using the '[%CurrentObject%]' token which you should get as option when using Ctra+Shift. Your XPath should end up looking something like this then:
[ModuleName.O2_O1 = '[%CurrentObject%]' ]
On a sidenote for this particular case, assuming you have a reference from O2 to O1, you could also use the connector menu or bring up the 'Entity (path)' menu from the data grid properties, and use it to select the entity path you are trying to follow. (Meaning you don't need to write an XPath for this)
Thanks that worked!