"NF3.0 Tree On Any Table" not working correctly in subtab
Description
Environment
Attachments
blocks
relates to

Activity
Dirk Niemeyer January 4, 2019 at 4:51 PM
Hi |~carlosruiz_globalqss], reason is found using Eclipse.
The NPE was raised by an orderline with missing content in column value
So the column needs to be configured as mandatory with a reasonable default.
The CCachedRowset seems to be fixed.
Regards,
Dirk
Carlos Ruiz January 1, 2019 at 3:15 PM
Thanks , the log is not clear - it's showing an error in CCachedRowset with stack trace, but the NPE doesn't have stack trace.
I just pushed a fix from Hiep about CCachedRowset - can you please check again?
If still failing I would need some steps to reproduce.
Regards,
Carlos Ruiz
Dirk Niemeyer January 1, 2019 at 1:46 PM
Hi ,
this seems to be the right approach. Works perfect in the SalesOrder window in the orderline subtab with hastree selected.
Still there is one situation producing an NPE: depending on the order document type an orderline subtype with tree or one without tree is used. Field DisplayLogic is driving visibilty depending on @C_DocTypeTarget_ID@<1000000 for example. When walking over the orders and switching from "with tree" to "without tree" I get 
Going the other direction is no problem.
As I am currently using a binary installation from iDempiereDaily #18 using OpenJDK Runtime Environment (build 11.0.1+13-Debian-3) I have to investigate further using debugging. An example log is attached.
Regards,
Dirk Niemeyer
Carlos Ruiz December 28, 2018 at 11:08 PM
OK, after analyzing all the case and doing some tests with different tables, I found the correct approach must be to define the link column directly on the tree.
So, I added the column AD_Tree.Parent_Column_ID
Expected behavior is:
if the parent column is empty it behaves as it's now - showing the whole tree
if the parent column is filled then it works as suggested in this ticket
Please note if the parent tab has a column with name AD_Tree_ID that will take precedence (like in Account Element).
I made a test with PA_Goal and parent column AD_User - it worked fine.
Also integrated the patch for PO but taking into account this new column.
/ - can you please peer review and test and provide feedback?
Regards,
Carlos Ruiz
Carlos Ruiz December 28, 2018 at 7:28 PM
Hi, revisiting this.
Documenting analysis of the new modification for PO.java:
The patch to PO.java throws an exception when adding a record to C_Activity table:
java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
Analyzing the code is also not desirable to define the link column as the first obtained with IsParent=Y - in a multi-parent table there is no guarantee that the first column returned is the one that you want to get for the update.
I see the code is written for a Value column that can be duplicated for different parents, not sure what you're trying to get there, the common case of a columns Value is that is unique per tenant, if you're trying to automatically add some Value per an order line attribute, maybe you can consider doing the Value unique adding as prefix the order docno, or the order ID.
That way the actual method of PO.java still works fine for driven by search key.
So, I think is better for the moment to not integrate the PO.java part.
I'm analyzing again the rest of the patch.
Regards,
Carlos Ruiz
I tried to apply "NF3.0 Tree On Any Table" to provide a better overview when having a high number of order lines in a sales order.
So I extended table OrderLines with field "IsSummary" as described in http://wiki.idempiere.org/en/NF3.0_Tree_On_Any_Table. To make it work technically (because of errors) I had to add field "Value" as well and to make it practically useful I had to add field "Name" as well. Then a tree is visible in the subtab of a sales order.
But the problem is that the tree is showing all order lines and does not filter regarding the related order.
I have created some patches against MTree and the related webui and swing functionality. They make it work in swing, webui is still missing the refresh when you move to another entry in the supertab.
and please review if this is the right approach.