details:   /erp/devel/pi/rev/e2c2208eeeaa
changeset: 9670:e2c2208eeeaa
user:      Antonio Moreno <antonio.moreno <at> openbravo.com>
date:      Mon Jan 10 11:41:18 2011 +0100
summary:   Set correct value in the parent column on NEW mode

details:   /erp/devel/pi/rev/7bbcf4f7d382
changeset: 9671:7bbcf4f7d382
user:      Antonio Moreno <antonio.moreno <at> openbravo.com>
date:      Mon Jan 10 11:53:24 2011 +0100
summary:   Added special case for IsActive columns on NEW mode

diffstat:

 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
 |  25 +++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

diffs (42 lines):

diff -r 9c32105ceeb3 -r 7bbcf4f7d382 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
     Mon Jan 10 11:30:39 2011 +0100
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
     Mon Jan 10 11:53:24 2011 +0100
@@ -200,7 +200,21 @@
           if (mode.equals("NEW")) {
             // On NEW mode, the values are computed through the UIDefinition 
(the defaults will be
             // used)
-            value = uiDef.getFieldProperties(field, false);
+            if (field.getColumn().isLinkToParentColumn() && parentRecord != 
null
+                && referencedEntityIsParent(parentRecord, field)) {
+              // If the column is link to the parent tab, we set its value as 
the parent id
+              RequestContext.get().setRequestParameter("inp" + 
Sqlc.TransformaNombreColumna(col),
+                  parentId);
+              value = uiDef.getFieldProperties(field, true);
+            } else if 
(field.getColumn().getDBColumnName().equalsIgnoreCase("IsActive")) {
+              // The Active column is always set to 'true' on new records
+              RequestContext.get().setRequestParameter("inp" + 
Sqlc.TransformaNombreColumna(col),
+                  "Y");
+              value = uiDef.getFieldProperties(field, true);
+            } else {
+              // Else, the default is used
+              value = uiDef.getFieldProperties(field, false);
+            }
           } else if (mode.equals("EDIT")
               || (mode.equals("CHANGE") && 
changeEventCols.contains(changedColumn))) {
             // On EDIT mode, the values are computed through the UIDefinition 
(the values have been
@@ -381,6 +395,15 @@
     return null;
   }
 
+  private boolean referencedEntityIsParent(BaseOBObject parentRecord, Field 
field) {
+    Entity parentEntity = parentRecord.getEntity();
+    Entity entity = ModelProvider.getInstance().getEntityByTableId(
+        field.getTab().getTable().getId());
+    Property property = 
entity.getPropertyByColumnName(field.getColumn().getDBColumnName());
+    Entity referencedEntity = property.getReferencedProperty().getEntity();
+    return referencedEntity.equals(parentEntity);
+  }
+
   private String parseDisplayLogic(Field field) {
     String displaylogic = field.getDisplayLogic();
     return parseDLExpression(displaylogic, field.getTab());

------------------------------------------------------------------------------
Gaining the trust of online customers is vital for the success of any company
that requires sensitive data to be transmitted over the Web.   Learn how to 
best implement a security strategy that keeps consumers' information secure 
and instills the confidence they need to proceed with transactions.
http://p.sf.net/sfu/oracle-sfdevnl 
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to