OK so this is pretty much solved. What you want to do when creating related list custom functions is fall back to the default SQL when 'SQL only' is required. Suppose your custom function looks something like:
Then you would add a couple of fallback lines:
Where you would choose to fallback either on 'get_dependents_list' or 'get_related_list' based on what your custom function sees as a 'relation'.
PHP Code:
public function get_custom_related($id, $tabid, $rel_tabid, $actions = false) {
global $adb;
// Do some custom stuff
}
PHP Code:
public function get_custom_related($id, $tabid, $rel_tabid, $actions = false) {
global $adb, $GetRelatedList_ReturnOnlyQuery;
if ($GetRelatedList_ReturnOnlyQuery) {
return $this->get_dependents_list($id, $tabid, $rel_tabid);
}
// Do some custom stuff
}