Optimization in getRelationQuery is not correct.

Finally we have to return to use a subselect, because our optimization breack
the query's semantic in reports.
If you create a report with secondary module, this optimization restrict the results to
have some relation with this secundary module because we add a inner join and the correct is to use
a left join to show results with primary modules without relations with secondary.