Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GenDoc: can't get to related record tree
#1
I have this in a gendoc template I use on an invoice:
Code:
{foreach MyModule}
{foreach CobroPago}
{CobroPago.reference}        € {CobroPago.amount}
{/foreach}
{/foreach}
Where 'MyModule' is a custom module that has is related to the invoice and the CobroPago (Payment) records are in turn related to 'MyModule'. For some reason I can show fields from 'MyModule' but not from the Payment (CobroPago) records. What am I doing wrong?
Reply
#2
Looks correct to me. I suppose the relation MyModule > CobroPago is a normal get_related_list?
Joe
TSolucio
Reply
#3
No, in fact there are two custom 'get_related_...' functions I built to create custom related lists. I was afraid that would be the issue. How could I get around this?
Reply
#4
that is probably the issue, depending on how you return the SQL probably.

first try using the direct document generation (accessing GenDoc module directly) with Debug active, to see if you can find some information about what it is doing on that foreach
Joe
TSolucio
Reply
#5
Is there some documentation on debugging gendoc templates? I'm not sure how to do it.
Reply
#6
first, go to the module: index.php?module=evvtgendoc&action=index
that will take you to a direct generator where you pick the template, module, language and if you want to see debug information or not
then the fun is trying to understand what the outputmeans :-)
Joe
TSolucio
Reply
#7
:-)
Cool, let me try that and report back here

OK so the debug didn't really do that much, other than provide me with some search terms to get me going in modules/evvtgendoc/compile.php. There I found this. I don't take this global variable assigment into account, nor do I adhere to query formatting of any kind in my related functions.

What I will try to do is check for the global '$GetRelatedList_ReturnOnlyQuery' in my custom related function and if so, call the 'regular' get_related_list function.
Reply
#8
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:
PHP Code:
public function get_custom_related($id$tabid$rel_tabid$actions false) {
 
   global $adb;
 
   // Do some custom stuff

Then you would add a couple of fallback lines:
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

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'.
Reply
#9
Very interesting
Thanks for sharing!
Joe
TSolucio
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)