fixed bug 17070: Reconcilliation child tab (cleared items) is not filtered by parent
authorAsier Lostalé <asier.lostale@openbravo.com>
Thu, 12 May 2011 10:28:21 +0200
changeset 12122 40eaf826d462
parent 12121 999211f9625a
child 12123 596c462d355a
fixed bug 17070: Reconcilliation child tab (cleared items) is not filtered by parent
modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationUtils.java
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationUtils.java	Thu May 12 10:00:22 2011 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationUtils.java	Thu May 12 10:28:21 2011 +0200
@@ -27,6 +27,7 @@
 import org.openbravo.base.model.Entity;
 import org.openbravo.base.model.ModelProvider;
 import org.openbravo.base.model.Property;
+import org.openbravo.client.kernel.KernelUtils;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBCriteria;
 import org.openbravo.dal.service.OBDal;
@@ -35,6 +36,7 @@
 import org.openbravo.model.ad.access.RoleOrganization;
 import org.openbravo.model.ad.access.User;
 import org.openbravo.model.ad.access.UserRoles;
+import org.openbravo.model.ad.datamodel.Column;
 import org.openbravo.model.ad.ui.Field;
 import org.openbravo.model.ad.ui.Tab;
 import org.openbravo.model.ad.ui.Window;
@@ -146,6 +148,23 @@
         }
       }
     }
+
+    // handle a special case: it is possible to define a column in the child tab to be linked to a
+    // secondary key in the parent tab
+    if (returnProperty == null) {
+      for (Column parentCol : parentTab.getTable().getADColumnList()) {
+        if (!parentCol.isSecondaryKey()) {
+          continue;
+        }
+        for (Column childCol : tab.getTable().getADColumnList()) {
+          if (childCol.isLinkToParentColumn()
+              && childCol.getDBColumnName().equalsIgnoreCase(parentCol.getDBColumnName())) {
+            returnProperty = KernelUtils.getInstance().getPropertyFromColumn(childCol);
+          }
+        }
+      }
+    }
+
     return (returnProperty != null ? returnProperty.getName() : "");
   }