Fixes Issue 22562: Project now Links to what it is defined in
authorDavid Miguelez <david.miguelez@openbravo.com>
Mon, 06 May 2013 11:20:40 +0200
changeset 20342 44f07dfabca9
parent 20341 0596b23501e1
child 20343 ac874a37e1f1
Fixes Issue 22562: Project now Links to what it is defined in
Application Dictionary by default.
src-db/database/sourcedata/AD_TABLE.xml
src/org/openbravo/erpCommon/utility/ReferencedLink.java
--- a/src-db/database/sourcedata/AD_TABLE.xml	Mon May 06 11:20:31 2013 +0200
+++ b/src-db/database/sourcedata/AD_TABLE.xml	Mon May 06 11:20:40 2013 +0200
@@ -1109,7 +1109,7 @@
 <!--203-->  <CLASSNAME><![CDATA[Project]]></CLASSNAME>
 <!--203-->  <ISVIEW><![CDATA[N]]></ISVIEW>
 <!--203-->  <ACCESSLEVEL><![CDATA[1]]></ACCESSLEVEL>
-<!--203-->  <AD_WINDOW_ID><![CDATA[800001]]></AD_WINDOW_ID>
+<!--203-->  <AD_WINDOW_ID><![CDATA[130]]></AD_WINDOW_ID>
 <!--203-->  <ISSECURITYENABLED><![CDATA[N]]></ISSECURITYENABLED>
 <!--203-->  <ISDELETEABLE><![CDATA[Y]]></ISDELETEABLE>
 <!--203-->  <ISHIGHVOLUME><![CDATA[N]]></ISHIGHVOLUME>
--- a/src/org/openbravo/erpCommon/utility/ReferencedLink.java	Mon May 06 11:20:31 2013 +0200
+++ b/src/org/openbravo/erpCommon/utility/ReferencedLink.java	Mon May 06 11:20:40 2013 +0200
@@ -39,6 +39,7 @@
 import org.openbravo.dal.service.OBQuery;
 import org.openbravo.data.Sqlc;
 import org.openbravo.erpCommon.businessUtility.Preferences;
+import org.openbravo.model.ad.datamodel.Table;
 import org.openbravo.model.ad.system.Language;
 import org.openbravo.model.ad.ui.Tab;
 import org.openbravo.model.ad.ui.WindowTrl;
@@ -205,14 +206,28 @@
         try {
           OBContext.setAdminMode();
           Project referencedProject = OBDal.getInstance().get(Project.class, strKeyReferenceId);
-          if (referencedProject != null && referencedProject.getProjectCategory() != null
-              && referencedProject.getProjectCategory().equals("S")) {
-            // Multiphase project
-            strWindowId = "130";
+          Table table = OBDal.getInstance().get(Table.class, strTableReferenceId);
+
+          if (table.getWindow() == null) {
+            // If there is no Window defined in Application Dictionary
+            if (referencedProject == null) {
+              // Service project
+              strWindowId = "800001";
+            } else if (referencedProject != null && referencedProject.getProjectCategory() != null
+                && referencedProject.getProjectCategory().equals("S")) {
+              // Multiphase project
+              strWindowId = "130";
+            }
           } else {
-            // Service project
-            strWindowId = "800001";
+            // Window defined in Application Dictionary
+            strWindowId = table.getWindow().getId();
+            if (referencedProject != null && referencedProject.getProjectCategory() != null
+                && referencedProject.getProjectCategory().equals("S")) {
+              // Multiphase project
+              strWindowId = "130";
+            }
           }
+
         } finally {
           OBContext.restorePreviousMode();
         }