Implemented open direct view functionality
authorMartin Taal <martin.taal@openbravo.com>
Tue, 14 Dec 2010 16:10:45 +0100
changeset 9131 1fee5f946d34
parent 9130 382532ad542b
child 9132 442f3f9bc63e
Implemented open direct view functionality
modules/.keep
modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_PARAMETER.xml
modules/org.openbravo.client.application/src-db/database/sourcedata/OBCLKER_TEMPLATE.xml
modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationComponentProvider.java
modules/org.openbravo.client.application/src/org/openbravo/client/application/navigationbarcomponents/templates/application-menu.js.ftl
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/entity-tab-mapping.js.ftl
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-field.js.ftl
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-grid.js.ftl
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ComputeSelectedRecordActionHandler.java
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/EntityWindowMappingComponent.java
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFormComponent.java
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinitionController.java
--- a/modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_PARAMETER.xml	Tue Dec 14 16:08:57 2010 +0100
+++ b/modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_PARAMETER.xml	Tue Dec 14 16:10:45 2010 +0100
@@ -93,7 +93,7 @@
         <default/>
         <onCreateDefault/>
       </column>
-      <column name="EVALUATEFIXEDVALUE" primaryKey="false" required="true" type="CHAR" size="1" autoIncrement="false">
+      <column name="EVALUATEFIXEDVALUE" primaryKey="false" required="false" type="CHAR" size="1" autoIncrement="false">
         <default><![CDATA[N]]></default>
         <onCreateDefault><![CDATA['N']]></onCreateDefault>
       </column>
--- a/modules/org.openbravo.client.application/src-db/database/sourcedata/OBCLKER_TEMPLATE.xml	Tue Dec 14 16:08:57 2010 +0100
+++ b/modules/org.openbravo.client.application/src-db/database/sourcedata/OBCLKER_TEMPLATE.xml	Tue Dec 14 16:10:45 2010 +0100
@@ -95,19 +95,6 @@
 <!--6DE62635998E4030B01DC2C4EA8567BE-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--6DE62635998E4030B01DC2C4EA8567BE--></OBCLKER_TEMPLATE>
 
-<!--7130F3674BCC434C8F939DFC2F58002B--><OBCLKER_TEMPLATE>
-<!--7130F3674BCC434C8F939DFC2F58002B-->  <OBCLKER_TEMPLATE_ID><![CDATA[7130F3674BCC434C8F939DFC2F58002B]]></OBCLKER_TEMPLATE_ID>
-<!--7130F3674BCC434C8F939DFC2F58002B-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
-<!--7130F3674BCC434C8F939DFC2F58002B-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--7130F3674BCC434C8F939DFC2F58002B-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
-<!--7130F3674BCC434C8F939DFC2F58002B-->  <NAME><![CDATA[Entity to Window Mapping]]></NAME>
-<!--7130F3674BCC434C8F939DFC2F58002B-->  <DESCRIPTION><![CDATA[Generates the mapping from entity to window/tabs maintaining them]]></DESCRIPTION>
-<!--7130F3674BCC434C8F939DFC2F58002B-->  <TEMPLATECLASSPATHLOCATION><![CDATA[/org/openbravo/client/application/templates/entity-tab-mapping.js.ftl]]></TEMPLATECLASSPATHLOCATION>
-<!--7130F3674BCC434C8F939DFC2F58002B-->  <TEMPLATE_LANGUAGE><![CDATA[OBCLFRE_Freemarker]]></TEMPLATE_LANGUAGE>
-<!--7130F3674BCC434C8F939DFC2F58002B-->  <COMPONENT_TYPE><![CDATA[OBUIAPP_MainLayout]]></COMPONENT_TYPE>
-<!--7130F3674BCC434C8F939DFC2F58002B-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--7130F3674BCC434C8F939DFC2F58002B--></OBCLKER_TEMPLATE>
-
 <!--91DD63545B674BE8801E1FA4F48FF4C6--><OBCLKER_TEMPLATE>
 <!--91DD63545B674BE8801E1FA4F48FF4C6-->  <OBCLKER_TEMPLATE_ID><![CDATA[91DD63545B674BE8801E1FA4F48FF4C6]]></OBCLKER_TEMPLATE_ID>
 <!--91DD63545B674BE8801E1FA4F48FF4C6-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationComponentProvider.java	Tue Dec 14 16:08:57 2010 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationComponentProvider.java	Tue Dec 14 16:10:45 2010 +0100
@@ -24,7 +24,6 @@
 
 import javax.enterprise.context.ApplicationScoped;
 
-import org.openbravo.client.application.window.EntityWindowMappingComponent;
 import org.openbravo.client.kernel.BaseComponentProvider;
 import org.openbravo.client.kernel.Component;
 import org.openbravo.client.kernel.ComponentProvider;
@@ -52,11 +51,6 @@
       component.setId(ApplicationConstants.MAIN_LAYOUT_ID);
       component.setParameters(parameters);
       return component;
-    } else if (componentId.equals(EntityWindowMappingComponent.COMPONENT_ID)) {
-      final EntityWindowMappingComponent component = getComponent(EntityWindowMappingComponent.class);
-      component.setId(EntityWindowMappingComponent.COMPONENT_ID);
-      component.setParameters(parameters);
-      return component;
     } else if (componentId.equals(ApplicationConstants.MAIN_LAYOUT_VIEW_COMPONENT_ID)) {
       final ViewComponent component = getComponent(ViewComponent.class);
       component.setId(ApplicationConstants.MAIN_LAYOUT_VIEW_COMPONENT_ID);
@@ -182,9 +176,6 @@
     // Application
     globalResources.add(createStaticResource("org.openbravo.client.kernel/"
         + ApplicationConstants.COMPONENT_TYPE + "/" + ApplicationConstants.MAIN_LAYOUT_ID, false));
-    globalResources.add(createStaticResource("org.openbravo.client.kernel/"
-        + ApplicationConstants.COMPONENT_TYPE + "/" + EntityWindowMappingComponent.COMPONENT_ID,
-        false));
 
     globalResources.add(createStaticResource(
         "web/org.openbravo.client.application/js/ob-view-manager.js", false));
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/navigationbarcomponents/templates/application-menu.js.ftl	Tue Dec 14 16:08:57 2010 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/navigationbarcomponents/templates/application-menu.js.ftl	Tue Dec 14 16:10:45 2010 +0100
@@ -118,6 +118,9 @@
         
     // overridden to get reliable custom style name
     getBaseStyle: function(record, rowNum, colNum){
+      if (!this.getField(colNum)) {
+        return '';
+      }
       var name = this.getField(colNum).name;
       return this.baseStyle +  name.substr(0, 1).toUpperCase() + name.substr(1) + 'Field';
     },
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/entity-tab-mapping.js.ftl	Tue Dec 14 16:08:57 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
- * Version 1.1  with a permitted attribution clause; you may not  use this
- * file except in compliance with the License. You  may  obtain  a copy of
- * the License at http://www.openbravo.com/legal/license.html 
- * Software distributed under the License  is  distributed  on  an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific  language  governing  rights  and  limitations
- * under the License.
- * The Original Code is Openbravo ERP.
- * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010 Openbravo SLU
- * All Rights Reserved.
- * Contributor(s):  ______________________________________.
- ************************************************************************
-*/
-
-// creates the mapping from entities to windows/tabs to support direct linking
-OB.EntityToWindowMapping = {    
-    <#list data.entityWindowMappings as mapping>
-    '${mapping.entityName?js_string}': {viewId: '_${mapping.windowId?js_string}', tabId: '${mapping.tabId?js_string}', tabTitle: '${mapping.tabTitle?js_string}'}<#if mapping_has_next>,</#if>
-    </#list>
-};
-
-OB.EntityToWindowMapping.openView = function(entity, recordId) {
-    var mapping = OB.EntityToWindowMapping[entity];
-    var openObject;
-    if (!mapping) {
-        // replace with a translatable warning
-        isc.warn(OB.I18N.getLabel('OBUIAPP_NoAccess'), 'OB');
-    } else {
-        // create shallow copy
-        openObject = isc.addProperties({}, mapping);
-        // set the record id
-        openObject.targetRecordId = recordId;
-        openObject.targetEntity = entity;
-        OB.Layout.ViewManager.openView(openObject.viewId, openObject);
-    }
-}; 
-
-
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-field.js.ftl	Tue Dec 14 16:08:57 2010 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-field.js.ftl	Tue Dec 14 16:10:45 2010 +0100
@@ -24,6 +24,8 @@
         <#if fieldDefinition.standardField>        
         type: '${fieldDefinition.type}',
         columnName: '${fieldDefinition.columnName?string}',
+        inpColumnName: '${fieldDefinition.inpColumnName?string}',
+        referencedKeyColumnName: '${fieldDefinition.referencedKeyColumnName?string}',
         required: ${fieldDefinition.required?string},
         </#if>
         ${fieldDefinition.fieldProperties}
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-grid.js.ftl	Tue Dec 14 16:08:57 2010 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-grid.js.ftl	Tue Dec 14 16:10:45 2010 +0100
@@ -27,6 +27,8 @@
         , targetEntity: '${field.targetEntity?js_string}'
         , title: '${field.title?js_string}'
         , showIf: '${field.initialShow?string}'
+        , inpColumnName: '${field.inpColumnName?string}'
+        , referencedKeyColumnName: '${field.referencedKeyColumnName?string}'        
        }
        <#if field_has_next>,</#if>
     </#list>
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ComputeSelectedRecordActionHandler.java	Tue Dec 14 16:08:57 2010 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ComputeSelectedRecordActionHandler.java	Tue Dec 14 16:10:45 2010 +0100
@@ -18,6 +18,7 @@
  */
 package org.openbravo.client.application.window;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -26,14 +27,19 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONObject;
 import org.openbravo.base.exception.OBException;
+import org.openbravo.base.model.Property;
+import org.openbravo.base.structure.BaseOBObject;
 import org.openbravo.client.application.MenuManager;
 import org.openbravo.client.application.MenuManager.MenuOption;
 import org.openbravo.client.kernel.BaseActionHandler;
 import org.openbravo.client.kernel.RequestContext;
 import org.openbravo.client.kernel.StaticResourceComponent;
 import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.ad.ui.Tab;
 import org.openbravo.model.ad.ui.Window;
 import org.openbravo.service.json.JsonConstants;
 
@@ -49,6 +55,8 @@
   private static final String WINDOW_ID = "windowId";
   private static final String TARGET_RECORD_ID = "targetRecordId";
   private static final String TARGET_ENTITY = "targetEntity";
+  private static final String TARGET_TAB_ID = "targetTabId";
+  private static final String RESULT = "result";
 
   @Inject
   private MenuManager menuManager;
@@ -96,13 +104,82 @@
     }
   }
 
-  private JSONObject processWindow(Window window, String recordId, String tabId) {
+  private JSONObject processWindow(Window window, String recordId, String entityName)
+      throws Exception {
+    // create the initial TabInfo
+    final Tab tab = getTab(window, entityName);
+    final BaseOBObject bob = OBDal.getInstance().get(entityName, recordId);
+    final TabInfo tabInfo = new TabInfo();
+    tabInfo.setRecord(bob);
+    tabInfo.setTab(tab);
+    final List<JSONObject> resultList = new ArrayList<JSONObject>();
+    resultList.add(tabInfo.getJSONObject());
+    TabInfo currentTabInfo = tabInfo;
+    while (currentTabInfo != null) {
+      currentTabInfo = getParentTabInfo(currentTabInfo.getRecord(), window);
+      if (currentTabInfo != null) {
+        resultList.add(0, currentTabInfo.getJSONObject());
+      }
+    }
     final JSONObject result = new JSONObject();
+    result.put(RESULT, new JSONArray(resultList));
+    return result;
+  }
 
-    return result;
+  private TabInfo getParentTabInfo(BaseOBObject childEntity, Window window) {
+    for (Property property : childEntity.getEntity().getProperties()) {
+      if (property.isParent()) {
+        final Tab tab = getTab(window, property.getTargetEntity().getName());
+        if (tab != null && childEntity.get(property.getName()) != null) {
+          final BaseOBObject parent = (BaseOBObject) childEntity.get(property.getName());
+          final TabInfo tabInfo = new TabInfo();
+          tabInfo.setRecord(parent);
+          tabInfo.setTab(tab);
+          return tabInfo;
+        }
+      }
+    }
+    return null;
+  }
+
+  private Tab getTab(Window window, String entityName) {
+    for (Tab tab : window.getADTabList()) {
+      if (tab.getTable().getName().equals(entityName)) {
+        return tab;
+      }
+    }
+    return null;
   }
 
   protected JSONObject execute(Map<String, Object> parameters, String data) {
     throw new UnsupportedOperationException();
   }
+
+  private class TabInfo {
+    private BaseOBObject record;
+    private Tab tab;
+
+    public Tab getTab() {
+      return tab;
+    }
+
+    public void setTab(Tab tab) {
+      this.tab = tab;
+    }
+
+    public BaseOBObject getRecord() {
+      return record;
+    }
+
+    public void setRecord(BaseOBObject record) {
+      this.record = record;
+    }
+
+    public JSONObject getJSONObject() throws Exception {
+      final JSONObject result = new JSONObject();
+      result.put(TARGET_RECORD_ID, getRecord().getId());
+      result.put(TARGET_TAB_ID, getTab().getId());
+      return result;
+    }
+  }
 }
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/EntityWindowMappingComponent.java	Tue Dec 14 16:08:57 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,130 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
- * Version 1.1  with a permitted attribution clause; you may not  use this
- * file except in compliance with the License. You  may  obtain  a copy of
- * the License at http://www.openbravo.com/legal/license.html 
- * Software distributed under the License  is  distributed  on  an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific  language  governing  rights  and  limitations
- * under the License.
- * The Original Code is Openbravo ERP.
- * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010 Openbravo SLU
- * All Rights Reserved.
- * Contributor(s):  ______________________________________.
- ************************************************************************
- */
-package org.openbravo.client.application.window;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.inject.Inject;
-
-import org.openbravo.client.application.MenuManager;
-import org.openbravo.client.application.MenuManager.MenuOption;
-import org.openbravo.client.kernel.BaseTemplateComponent;
-import org.openbravo.client.kernel.Template;
-import org.openbravo.dal.core.OBContext;
-import org.openbravo.dal.service.OBDal;
-import org.openbravo.model.ad.ui.Tab;
-
-/**
- * Component for creating mappings from entities to windows/tabs. It also computes the parent tabs
- * and parent properties from an entity to its parents and grand parents in the same window. This is
- * used to support correct opening of tabs/forms when a child tab is opened directly.
- * 
- * @author mtaal
- */
-public class EntityWindowMappingComponent extends BaseTemplateComponent {
-
-  private static final String TEMPLATE_ID = "7130F3674BCC434C8F939DFC2F58002B";
-  public static final String COMPONENT_ID = "EntityWindowMappingComponent";
-
-  @Inject
-  private MenuManager menuManager;
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.openbravo.client.kernel.BaseTemplateComponent#getComponentTemplate()
-   */
-  @Override
-  protected Template getComponentTemplate() {
-    return OBDal.getInstance().get(Template.class, TEMPLATE_ID);
-  }
-
-  protected String getModulePackageName() {
-    return "org.openbravo.client.application";
-  }
-
-  public List<EntityWindowMapping> getEntityWindowMappings() {
-    final List<MenuOption> menuOptions = menuManager.getSelectableMenuOptions();
-    final List<EntityWindowMapping> mappings = new ArrayList<EntityWindowMapping>();
-    final List<String> mappedEntity = new ArrayList<String>();
-    for (MenuOption menuOption : menuOptions) {
-      if (menuOption.getType() == MenuManager.MenuEntryType.Window) {
-        for (Tab tab : menuOption.getMenu().getWindow().getADTabList()) {
-          if (mappedEntity.contains(tab.getTable().getName())) {
-            continue;
-          }
-          final EntityWindowMapping mapping = new EntityWindowMapping();
-          mapping.setEntityName(tab.getTable().getName());
-          mapping.setTabTitle(menuOption.getLabel());
-          mapping.setWindowId(menuOption.getMenu().getWindow().getId());
-          mapping.setTabId(menuOption.getTab().getId());
-          mappings.add(mapping);
-          mappedEntity.add(mapping.getEntityName());
-        }
-      }
-    }
-    return mappings;
-  }
-
-  public String getETag() {
-    final String eTag = super.getETag();
-    return OBContext.getOBContext().getRole().getId() + eTag;
-  }
-
-  public static class EntityWindowMapping {
-    private String entityName;
-    private String windowId;
-    private String tabId;
-    private String tabTitle;
-
-    public String getEntityName() {
-      return entityName;
-    }
-
-    public void setEntityName(String entityName) {
-      this.entityName = entityName;
-    }
-
-    public String getWindowId() {
-      return windowId;
-    }
-
-    public void setWindowId(String windowId) {
-      this.windowId = windowId;
-    }
-
-    public String getTabId() {
-      return tabId;
-    }
-
-    public void setTabId(String tabId) {
-      this.tabId = tabId;
-    }
-
-    public String getTabTitle() {
-      return tabTitle;
-    }
-
-    public void setTabTitle(String tabTitle) {
-      this.tabTitle = tabTitle;
-    }
-
-  }
-}
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFormComponent.java	Tue Dec 14 16:08:57 2010 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFormComponent.java	Tue Dec 14 16:10:45 2010 +0100
@@ -33,6 +33,7 @@
 import org.openbravo.client.kernel.reference.UIDefinition;
 import org.openbravo.client.kernel.reference.UIDefinitionController;
 import org.openbravo.dal.service.OBDal;
+import org.openbravo.data.Sqlc;
 import org.openbravo.model.ad.ui.Field;
 import org.openbravo.model.ad.ui.FieldGroup;
 import org.openbravo.model.ad.ui.Tab;
@@ -118,6 +119,11 @@
     public boolean getStandardField();
 
     public String getFieldProperties();
+
+    public String getInpColumnName();
+
+    public String getReferencedKeyColumnName();
+
   }
 
   public class OBViewField implements OBViewFieldDefinition {
@@ -162,6 +168,23 @@
       return property.getColumnName().toLowerCase();
     }
 
+    public String getInpColumnName() {
+      return "inp" + Sqlc.TransformaNombreColumna(property.getColumnName());
+    }
+
+    public String getReferencedKeyColumnName() {
+      if (property.isOneToMany() || property.isPrimitive()) {
+        return "";
+      }
+      Property prop;
+      if (property.getReferencedProperty() == null) {
+        prop = property.getTargetEntity().getIdProperties().get(0);
+      } else {
+        prop = property.getReferencedProperty();
+      }
+      return prop.getColumnName();
+    }
+
     public String getLabel() {
       // compute the label
       if (label == null) {
@@ -220,6 +243,14 @@
       return "";
     }
 
+    public String getInpColumnName() {
+      return "";
+    }
+
+    public String getReferencedKeyColumnName() {
+      return "";
+    }
+
     public String getLabel() {
       // compute the label
       if (label == null) {
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java	Tue Dec 14 16:08:57 2010 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java	Tue Dec 14 16:10:45 2010 +0100
@@ -31,6 +31,7 @@
 import org.openbravo.client.kernel.reference.UIDefinition;
 import org.openbravo.client.kernel.reference.UIDefinitionController;
 import org.openbravo.dal.service.OBDal;
+import org.openbravo.data.Sqlc;
 import org.openbravo.model.ad.ui.Field;
 import org.openbravo.model.ad.ui.Tab;
 import org.openbravo.service.json.JsonConstants;
@@ -89,6 +90,7 @@
       return fields;
     }
     fields = new ArrayList<LocalField>();
+    final List<String> windowEntities = getWindowEntities();
     final List<Field> sortedFields = new ArrayList<Field>(tab.getADFieldList());
     Collections.sort(sortedFields, new GridFieldComparator());
 
@@ -96,7 +98,7 @@
     for (Field fld : sortedFields) {
       if (fld.isActive() && fld.isShowInGridView()) {
         final Property prop = KernelUtils.getInstance().getPropertyFromColumn(fld.getColumn());
-        if (prop.isParent()) {
+        if (prop.isParent() && windowEntities.contains(prop.getTargetEntity().getName())) {
           continue;
         }
         if (prop.isId()) {
@@ -114,7 +116,7 @@
     for (Field fld : sortedFields) {
       if (fld.isActive() && !fld.isShowInGridView()) {
         final Property prop = KernelUtils.getInstance().getPropertyFromColumn(fld.getColumn());
-        if (prop.isParent()) {
+        if (prop.isParent() && windowEntities.contains(prop.getTargetEntity().getName())) {
           continue;
         }
         if (prop.isId()) {
@@ -150,6 +152,23 @@
     private UIDefinition uiDefinition;
     private boolean initialShow;
 
+    public String getInpColumnName() {
+      return "inp" + Sqlc.TransformaNombreColumna(property.getColumnName());
+    }
+
+    public String getReferencedKeyColumnName() {
+      if (property.isOneToMany() || property.isPrimitive()) {
+        return "";
+      }
+      Property prop;
+      if (property.getReferencedProperty() == null) {
+        prop = property.getTargetEntity().getIdProperties().get(0);
+      } else {
+        prop = property.getReferencedProperty();
+      }
+      return prop.getColumnName();
+    }
+
     public String getGridFieldProperties() {
       return uiDefinition.getGridFieldProperties(field);
     }
@@ -243,4 +262,12 @@
 
   }
 
+  private List<String> getWindowEntities() {
+    final List<String> windowEntities = new ArrayList<String>();
+    for (Tab localTab : tab.getWindow().getADTabList()) {
+      windowEntities.add(localTab.getTable().getName());
+    }
+    return windowEntities;
+  }
+
 }
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js	Tue Dec 14 16:08:57 2010 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js	Tue Dec 14 16:10:45 2010 +0100
@@ -5,7 +5,7 @@
  * Version 1.1  with a permitted attribution clause; you may not  use this
  * file except in compliance with the License. You  may  obtain  a copy of
  * the License at http://www.openbravo.com/legal/license.html
- * Software distributed under the License  is  distributed  on  an "AS IS"
+ * Software distributed under the License  is  distribfuted  on  an "AS IS"
  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
  * License for the specific  language  governing  rights  and  limitations
  * under the License.
@@ -26,6 +26,7 @@
   viewProperties: null,
   
   initWidget: function(){
+    var standardWindow = this;
     this.toolBar = isc.OBToolbar.create({
       height: this.toolBarHeight,
       minHeight: this.toolBarHeight,
@@ -61,10 +62,8 @@
     })]);
     
     this.addMember(this.toolBar);
-        
-    // todo: set in the correct childtab...
-    // note must be set before the OBStandardView is created
-    this.viewProperties.targetRecordId = this.targetRecordId;
+    
+    this.viewProperties.standardWindow = this;
     
     this.view = isc.OBStandardView.create(this.viewProperties);
     this.addMember(this.view);
@@ -76,9 +75,30 @@
     this.view.tabTitle = this.tabTitle;
   },
   
-  setViewTabId: function(viewTabId) {
+  draw: function(){
+    var standardWindow = this;
+    var ret = this.Super('draw', arguments);
+    
+    if (this.targetRecordId) {
+      OB.RemoteCallManager.call('org.openbravo.client.application.window.ComputeSelectedRecordActionHandler', null, {
+        targetEntity: this.targetEntity,
+        targetRecordId: this.targetRecordId,
+        windowId: this.windowId
+      }, function(response, data, request){
+        standardWindow.directTabInfo = data.result;
+        standardWindow.view.openDirectTab();
+      });
+      delete this.targetRecordId;
+      delete this.targetTabId;
+      delete this.targetEntity;
+    }
+    
+    return ret;
+  },
+  
+  setViewTabId: function(viewTabId){
     this.view.viewTabId = viewTabId;
-    this.viewTabId = viewTabId;    
+    this.viewTabId = viewTabId;
   },
   
   doHandleClick: function(){
@@ -139,39 +159,6 @@
 
 isc.OBStandardView.addProperties({
 
-  state: isc.OBStandardView.STATE_MID,
-  previousState: isc.OBStandardView.STATE_TOP_MAX,
-  
-  doHandleClick: function(){
-    if (!this.childTabSet) {
-      return;
-    }
-    if (this.state !== isc.OBStandardView.STATE_BOTTOM_MAX) {
-      this.setHalfSplit();
-      this.previousState = isc.OBStandardView.STATE_TOP_MAX;
-      this.state = isc.OBStandardView.STATE_MID;
-    }
-  },
-  
-  doHandleDoubleClick: function(){
-    var tempState;
-    if (!this.childTabSet) {
-      return;
-    }
-    tempState = this.state;
-    this.state = this.previousState;
-    if (this.previousState === isc.OBStandardView.STATE_BOTTOM_MAX) {
-      this.setBottomMaximum();
-    } else if (this.previousState === isc.OBStandardView.STATE_MID) {
-      this.setHalfSplit();
-    } else if (this.previousState === isc.OBStandardView.STATE_TOP_MAX) {
-      this.setTopMaximum();
-    } else {
-      isc.warn(this.previousState + ' not supported ');
-    }
-    this.previousState = tempState;
-  },
-  
   // properties used by the ViewManager, only relevant in case this is the
   // top
   // view shown directly in the main tab
@@ -253,19 +240,27 @@
   padding: 0,
   overflow: 'hidden',
   
+  // set if one record has been selected
+  lastRecordSelected: null,
+  
+  // ** {{{ refreshContents }}} **
+  // Should the contents listgrid/forms be refreshed when the tab
+  // gets selected and shown to the user.
+  refreshContents: true,
+  
+  state: isc.OBStandardView.STATE_MID,
+  previousState: isc.OBStandardView.STATE_TOP_MAX,
+  
   initWidget: function(properties){
     var isRootView = !this.parentProperty;
     
-    // this value must be set before passing on to build structure
-    this.targetRecordId = properties.targetRecordId;
-
     if (isRootView) {
       this.buildStructure();
     }
     
-    OB.TestRegistry.register('org.openbravo.client.application.ViewGrid_' + this.tabId, this.viewGrid);        
+    OB.TestRegistry.register('org.openbravo.client.application.ViewGrid_' + this.tabId, this.viewGrid);
     OB.TestRegistry.register('org.openbravo.client.application.ViewForm_' + this.tabId, this.viewForm);
-
+    
     this.Super('initWidget', arguments);
   },
   
@@ -286,7 +281,7 @@
         this.members[1].setHeight('50%');
         this.childTabSet.setState(isc.OBStandardView.STATE_IN_MID);
         this.childTabSet.selectTab(this.childTabSet.tabs[0]);
-
+        
         OB.TestRegistry.register('org.openbravo.client.application.ChildTabSet_' + this.tabId, this.viewForm);
       } else {
         this.members[0].setHeight('100%');
@@ -296,7 +291,11 @@
   
   setDataSource: function(ds){
     this.dataSource = ds;
+    
     if (this.viewGrid) {
+      if (this.targetRecordId) {
+        this.viewGrid.targetRecordId = this.targetRecordId;
+      }
       this.viewGrid.setDataSource(this.dataSource, this.viewGrid.completeFields || this.viewGrid.fields);
       if (!this.parentProperty) {
         this.viewGrid.fetchData();
@@ -327,7 +326,7 @@
   createMainParts: function(){
     var isRootView = !this.parentProperty;
     var me = this;
-    if (this.tabId.length > 0) {
+    if (this.tabId && this.tabId.length > 0) {
       this.formGridLayout = isc.HLayout.create({
         width: '100%',
         height: '*',
@@ -338,9 +337,6 @@
         this.viewGrid.setWidth('100%');
         this.viewGrid.view = this;
         this.formGridLayout.addMember(this.viewGrid);
-        if (this.targetRecordId) {
-          this.viewGrid.targetRecordId = this.targetRecordId;
-        }
       }
       
       if (this.viewForm) {
@@ -378,6 +374,8 @@
   // this
   // parent.
   addChildView: function(childView){
+    childView.standardWindow = this.standardWindow;
+    
     childView.parentView = this;
     childView.parentTabSet = this.childTabSet;
     
@@ -394,17 +392,12 @@
     childView.tab = this.childTabSet.tabs[this.childTabSet.tabs.length - 1];
     
     OB.TestRegistry.register('org.openbravo.client.application.ChildTab_' + this.tabId + "_" + childView.tabId, childView.tab);
-
+    
   },
   
-  // ** {{{ refreshContents }}} **
-  // Should the contents listgrid/forms be refreshed when the tab
-  // gets selected and shown to the user.
-  refreshContents: true,
-  
   doRefreshContents: function(){
     // refresh when shown
-    if (this.parentTabSet.state === isc.OBStandardView.STATE_MIN) {
+    if (this.parentTabSet && this.parentTabSet.state === isc.OBStandardView.STATE_MIN) {
       return;
     }
     if (!this.refreshContents) {
@@ -416,10 +409,7 @@
     if (!this.viewGrid.isVisible()) {
       this.switchFormGridVisibility();
     }
-    // filter and select the first record
-    this.viewGrid.filterData({}, function(){
-      //      me.viewGrid.selectRecord(0);
-    });
+    this.viewGrid.refreshContents();
     this.refreshContents = false;
   },
   
@@ -438,11 +428,41 @@
     this.updateTabTitle();
   },
   
+  doHandleClick: function(){
+    if (!this.childTabSet) {
+      return;
+    }
+    if (this.state !== isc.OBStandardView.STATE_BOTTOM_MAX) {
+      this.setHalfSplit();
+      this.previousState = isc.OBStandardView.STATE_TOP_MAX;
+      this.state = isc.OBStandardView.STATE_MID;
+    }
+  },
+  
+  doHandleDoubleClick: function(){
+    var tempState;
+    if (!this.childTabSet) {
+      return;
+    }
+    tempState = this.state;
+    this.state = this.previousState;
+    if (this.previousState === isc.OBStandardView.STATE_BOTTOM_MAX) {
+      this.setBottomMaximum();
+    } else if (this.previousState === isc.OBStandardView.STATE_MID) {
+      this.setHalfSplit();
+    } else if (this.previousState === isc.OBStandardView.STATE_TOP_MAX) {
+      this.setTopMaximum();
+    } else {
+      isc.warn(this.previousState + ' not supported ');
+    }
+    this.previousState = tempState;
+  },
+  
   // ** {{{ editRecord }}} **
   // Opens the edit form and selects the record in the grid, will refresh
   // child views also
   editRecord: function(record){
-    
+  
     // this.recordSelected(record);
     this.viewForm.editRecord(record);
     this.viewForm.clearErrors();
@@ -450,16 +470,76 @@
       this.switchFormGridVisibility();
     }
     this.viewGrid.doSelectSingleRecord(record);
-    if (this.targetRecordId) {
-      this.targetRecordId = null;
+  },
+  
+  // check if a child tab should be opened directly
+  openDirectChildTab: function(){
+    if (this.childTabSet) {
+      var i, tabs = this.childTabSet.tabs;
+      for (i = 0; i < tabs.length; i++) {
+        if (tabs[i].pane.openDirectTab()) {                    
+          return;
+        }
+      }
     }
+    
+    // no child tabs to open anymore, show ourselves as the default view
+    // open this view
+    if (this.parentTabSet) {
+      this.parentTabSet.setState(isc.OBStandardView.STATE_MID);
+    } else {
+      this.doHandleClick();
+    }
+    // remove this info
+    delete this.standardWindow.directTabInfo;
+  },
+  
+  openDirectTab: function(){
+    if (!this.dataSource) {
+      // wait for the datasource to arrive
+      this.delayCall('openDirectTab', null, 200, this);
+      return;
+    }
+    var i, thisView = this, tabInfos = this.standardWindow.directTabInfo;
+    if (!tabInfos) {
+      return;
+    }
+    for (i = 0; i < tabInfos.length; i++) {
+      if (tabInfos[i].targetTabId === this.tabId) {
+        // found it...
+        this.viewGrid.targetRecordId = tabInfos[i].targetRecordId;
+                      
+        if (this.parentTabSet && this.parentTabSet.getSelectedTab() !== this.tab) {
+          this.parentTabSet.selectTab(this.tab);
+        } else {
+          // make sure that the content gets refreshed
+          this.refreshContents = true;
+          // refresh and open a child view when all is done
+          this.doRefreshContents();
+        }
+        return true;
+      }
+    }
+    return false;
   },
   
   // ** {{{ recordSelected }}} **
   // Is called when a record get's selected. Will refresh direct child views
-  // (which
-  // will again refresh their children.
+  // which will again refresh their children.
   recordSelected: function(){
+    this.fireOnPause("recordSelected", {
+      target: this,
+      methodName: "doRecordSelected",
+      args: []
+    }, this.fetchDelay);
+  },
+  
+  doRecordSelected: function(){
+    // no change go away
+    if (this.viewGrid.getSelectedRecords().length === 1 && this.viewGrid.getSelectedRecord() === this.lastRecordSelected) {
+      return;
+    }
+    
     var tabViewPane = null;
     
     // refresh the tabs
@@ -472,6 +552,7 @@
     // and recompute the count:
     this.updateChildCount();
     this.updateTabTitle();
+    this.lastRecordSelected = this.viewGrid.getSelectedRecord();
   },
   
   // ** {{{ parentRecordSelected }}} **
@@ -499,12 +580,7 @@
       isc.Log.logDebug('ParentRecordSelected: View visible ' + this.tabTitle, 'OB');
       var me = this;
       if (this.viewGrid) {
-        // filter and select the first record
-        this.viewGrid.filterData({}, function(){
-          // will cascade parentRecordSelected to children
-          // me.viewGrid.selectRecord(0);
-          // disabled for now, is done using the for-loop below
-        });
+        this.viewGrid.refreshContents();
       }
       if (this.viewForm) {
         this.viewForm.clearValues();
@@ -550,7 +626,7 @@
     callback = function(resp, data, req){
       var tab, tabPane;
       var tabInfos = data.result;
-      if (tabInfos.length !== me.childTabSet.tabs.length) {
+      if (!tabInfos || tabInfos.length !== me.childTabSet.tabs.length) {
         // error, something has changed
         return;
       }
@@ -594,7 +670,7 @@
       // only show a count if there is one parent
       if (this.parentView.viewGrid.getSelectedRecords().length !== 1) {
         this.parentTabSet.setTabTitle(this.tab, this.originalTabTitle);
-      } else if (this.recordCount){
+      } else if (this.recordCount) {
         this.parentTabSet.setTabTitle(this.tab, this.originalTabTitle + ' (' + this.recordCount + ')');
       }
     }
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js	Tue Dec 14 16:08:57 2010 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js	Tue Dec 14 16:10:45 2010 +0100
@@ -23,6 +23,42 @@
 OB.Utilities.Date = {};
 OB.Utilities.Number = {};
 
+// ** {{{OB.Utilities.openDirectView}}} **
+// Open the correct view for a passed in target definition, coming from a certain source Window.
+OB.Utilities.openDirectView = function(sourceWindowId, keyColumn, targetEntity, recordId){
+  var actionURL = OB.Application.contextUrl + 'utility/ReferencedLink.html';
+  
+  var callback = function(response, data, request){
+    var openObject = {
+      viewId: '_' + data.windowId,
+      targetEntity: response.clientContext.targetEntity,
+      targetRecordId: data.recordId,
+      targetTabId: data.tabId,
+      tabTitle: data.tabTitle
+    };
+    OB.Layout.ViewManager.openView(openObject.viewId, openObject);
+  }
+  
+  var reqObj = {
+    params: {
+      Command: 'JSON',
+      inpEntityName: targetEntity,
+      inpKeyReferenceId: recordId,
+      inpwindowId: sourceWindowId,
+      inpKeyReferenceColumnName: keyColumn
+    },
+    clientContext: {
+      targetEntity: targetEntity
+    },
+    callback: callback,
+    evalResult: true,
+    httpMethod: 'GET',
+    useSimpleHttp: true,
+    actionURL: actionURL
+  };
+  var request = isc.RPCManager.sendRequest(reqObj);
+};
+
 // ** {{{OB.Utilities.hasUrlParameter}}} **
 // Returns true if the url has a certain parameter with a certain value.
 OB.Utilities.hasUrlParameter = function(name, value){
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js	Tue Dec 14 16:08:57 2010 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js	Tue Dec 14 16:10:45 2010 +0100
@@ -52,7 +52,7 @@
   // ** {{{ editGrid }}} **
   // Controls if an edit link column is created in the grid, set to false to
   // prevent this.
-  editGrid: true,  
+  editGrid: true,
   
   // ** {{{ editLinkFieldProperties }}} **
   // The properties of the ListGridField created for the edit links.
@@ -109,7 +109,6 @@
   
   emptyMessage: OB.I18N.getLabel('OBUIAPP_NoDataInGrid'),
   discardEditsSaveButtonTitle: OB.I18N.getLabel('UINAVBA_Save'),
-  loadingDataMessage: '&nbsp;',  
   
   // keeps track if we are in objectSelectionMode or in toggleSelectionMode
   // objectSelectionMode = singleRecordSelection === true  
@@ -117,7 +116,24 @@
   
   dataProperties: {
     useClientFiltering: false,
-    useClientSorting: false
+    useClientSorting: false,
+    
+    transformData: function(newData, dsResponse){
+      // correct the length if there is already data in the localData array
+      if (this.localData) {
+        for (var i = dsResponse.endRow + 1; i < this.localData.length; i++) {
+          if (!Array.isLoading(this.localData[i]) && this.localData[i]) {
+            dsResponse.totalRows = i + 1;
+          } else {
+            break;
+          }
+        }
+      }
+      if (this.localData && this.localData[dsResponse.totalRows]) {
+        this.localData[dsResponse.totalRows] = null;
+      }
+      return this.Super('transformData', arguments);
+    }
   },
   
   recordComponentPoolingMode: 'recycle',
@@ -167,7 +183,6 @@
   
   initWidget: function(){
     var thisGrid = this, localEditLinkField;
-    this.tallBaseStyle = this.tallBaseStyleView;
     if (this.editGrid) {
       // add the edit pencil in the beginning
       localEditLinkField = isc.addProperties({}, this.editLinkFieldProperties);
@@ -196,6 +211,25 @@
     this.Super('initWidget', arguments);
   },
   
+  headerClick: function(fieldNum, header){
+    var field = this.fields[fieldNum];
+    if (this.isCheckboxField(field) && this.singleRecordSelection) {
+      this.deselectAllRecords();
+      this.singleRecordSelection = false;
+    }
+    return this.Super('headerClick', arguments);
+  },
+  
+  deselectAllRecords: function(){
+    this.allSelected = false;
+    return this.Super('deselectAllRecords', arguments);
+  },
+  
+  selectAllRecords: function(){
+    this.allSelected = true;
+    return this.Super('selectAllRecords', arguments);
+  },
+  
   updateRowCountDisplay: function(){
     var newValue = '';
     if (this.data.getLength() > this.dataPageSize) {
@@ -210,25 +244,72 @@
     }
   },
   
+  refreshContents: function(callback){
+    var criteria = this.getFilterEditorCriteria() || {};
+    var context = {
+      showPrompt: false,
+      textMatchStyle: this.autoFetchTextMatchStyle
+    };
+    this.filterData(criteria, callback, context);
+  },
+  
   dataArrived: function(startRow, endRow){
     var ret = this.Super('dataArrived', arguments);
     this.updateRowCountDisplay();
     this.updateSelectedCountDisplay();
     
     if (this.targetRecordId) {
-      var gridRecord = this.data.find('id', this.targetRecordId);    
-      this.view.editRecord(gridRecord);
-      this.targetRecordId = null;
-      this.body.scrollTo(null, startRow);
-      this.body.doneFastScrolling();
+      this.delayedHandleTargetRecord(startRow, endRow);
     }
     
     return ret;
   },
   
+  // handle the target record when the body has been drawn
+  delayedHandleTargetRecord: function(startRow, endRow){
+    var rowTop, recordIndex, i, data = this.data;
+    if (!this.targetRecordId) {
+      return;
+    }
+    if (this.body) {
+      var gridRecord = data.find('id', this.targetRecordId);
+      
+      // no grid record found, stop here
+      if (!gridRecord) {
+        return;
+      }
+      recordIndex = this.getRecordIndex(gridRecord);
+      
+      this.targetRecordId = null;
+      if (data.criteria) {
+        data.criteria._targetRecordId = null;
+      }
+      
+      for (i = 0; i < startRow; i++) {
+        if (Array.isLoading(data.localData[i])) {
+          data.localData[i] = null;
+        }
+      }
+      
+      this.scrollRecordIntoView(recordIndex, false);
+      this.view.editRecord(gridRecord);
+      
+      isc.Page.waitFor(this, "delayedHandleTargetRecord", {
+        method: this.view.openDirectChildTab(),
+        args: [],
+        target: this.view
+      });
+    } else {
+      // wait a bit longer
+      this.delayCall('delayedHandleTargetRecord', [startRow, endRow], 500, this);
+    }
+  },
+  
   filterData: function(criteria, callback, requestProperties){
-    // so that the prompt knows the modal target 
-    this.setModalTarget();
+    if (!requestProperties) {
+      requestProperties = {};
+    }
+    requestProperties.showPrompt = false;
     
     criteria = this.convertCriteria(criteria);
     var theView = this.view;
@@ -242,17 +323,11 @@
     return this.Super('filterData', [criteria, newCallBack, requestProperties]);
   },
   
-  setModalTarget : function() {
-    if (this.view && this.view.formGridLayout) {
-      OB.OBModalTarget = this.view.formGridLayout;
-    } else {
-      OB.OBModalTarget = this;
+  fetchData: function(criteria, callback, requestProperties){
+    if (!requestProperties) {
+      requestProperties = {};
     }
-  },
-  
-  fetchData: function(criteria, callback, requestProperties){
-    // so that the prompt knows the modal target 
-    this.setModalTarget();
+    requestProperties.showPrompt = false;
     
     criteria = this.convertCriteria(criteria);
     var theView = this.view;
@@ -309,6 +384,10 @@
     var index = 0, selectedValues;
     var fkFieldsLength = this.foreignKeyFieldNames.getLength(), filterValue = null;
     
+    if (this.targetRecordId) {
+      criteria._targetRecordId = this.targetRecordId;
+    }
+    
     if (this.view.parentProperty) {
       if (!this.view.parentView) {
         criteria[this.view.parentProperty] = '-1';
@@ -327,10 +406,6 @@
       }
     }
     
-    if (this.targetRecordId) {
-      criteria._targetRecordId = this.targetRecordId;
-    }
-    
     // now repair the filtering on foreign keys to use the identifier
     //    for (index = 0; index < fkFieldsLength; index++) {
     //      if (criteria[this.foreignKeyFieldNames[index]]) {
@@ -358,6 +433,7 @@
   //+++++++++++++++++++++++++++++ Context menu on record click +++++++++++++++++++++++
   
   makeCellContextItems: function(record, rowNum, colNum){
+    var sourceWindow = this.view.standardWindow.windowId;
     var menuItems = [];
     var field = this.getField(colNum);
     var grid = this;
@@ -389,7 +465,7 @@
         }
       });
     }
-    if (field.foreignKeyField) {      
+    if (field.foreignKeyField) {
       menuItems.add({
         title: OB.I18N.getLabel('OBUIAPP_OpenOnTab'),
         click: function(){
@@ -398,7 +474,7 @@
           if (dotIndex !== -1) {
             fldName = fldName.substring(0, dotIndex);
           }
-          OB.EntityToWindowMapping.openView(field.targetEntity, record[fldName]);
+          OB.Utilities.openDirectView(sourceWindow, field.referencedKeyColumnName, field.targetEntity, record[fldName]);
         }
       });
     }
@@ -566,13 +642,20 @@
     }
     this.singleRecordSelection = true;
     this.selectSingleRecord(record);
+    
+    // deselect the checkbox in the top
+    var fieldNum = this.getCheckboxFieldPosition(), field = this.fields[fieldNum];
+    var icon = this.checkboxFieldFalseImage || this.booleanFalseImage;
+    var title = this.getValueIconHTML(icon, field);
+    
+    this.setFieldTitle(fieldNum, title);
   },
   
   // overridden to prevent the checkbox to be shown when only one 
   // record is selected.
   getCellValue: function(record, recordNum, fieldNum, gridBody){
     var field = this.fields[fieldNum];
-    if (!field) {
+    if (!field || this.allSelected) {
       return this.Super('getCellValue', arguments);
     }
     // do all the cases which are handled in the super directly
@@ -582,7 +665,7 @@
       if (!this.body.canSelectRecord(record)) {
         // record cannot be selected but we want the space allocated for the checkbox anyway.
         icon = '[SKINIMG]/blank.gif';
-      } else if (this.singleRecordSelection) {
+      } else if (this.singleRecordSelection && !this.allSelected) {
         // always show the false image
         icon = (this.checkboxFieldFalseImage || this.booleanFalseImage);
       } else {
@@ -636,7 +719,6 @@
   },
   
   showInlineEditor: function(rowNum, colNum, newCell, newRow, suppressFocus){
-    this.tallBaseStyle = this.tallBaseStyleEdit;
     var result = this.Super('showInlineEditor', arguments);
     
     var record = this.getRecord(rowNum);
@@ -648,7 +730,6 @@
   },
   
   hideInlineEditor: function(){
-    this.tallBaseStyle = this.tallBaseStyleView;
     isc.Log.logDebug('hideInlineEditor ' + this.getEditRow(), 'OB');
     var rowNum = this.getEditRow();
     var record = this.getRecord(rowNum);
@@ -738,7 +819,7 @@
     buttonSeparator2 = isc.OBGridToolStripSeparator.create({});
     
     this.OBGridToolStrip = isc.OBGridToolStrip.create({
-      members: [formIcon, buttonSeparator1, editIcon, cancelIcon, buttonSeparator2, saveIcon]
+      members: [editIcon, buttonSeparator1, formIcon, cancelIcon, buttonSeparator2, saveIcon]
     });
     
     this.addMember(this.OBGridToolStrip);
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinitionController.java	Tue Dec 14 16:08:57 2010 +0100
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinitionController.java	Tue Dec 14 16:10:45 2010 +0100
@@ -151,6 +151,7 @@
           final Class<?> clz = OBClassLoader.getInstance().loadClass(
               buttonReference.getOBCLKERUIDefinitionList().get(0).getImplementationClassname());
           buttonDefinition = (UIDefinition) clz.newInstance();
+          buttonDefinition.setReference(buttonReference);
         } catch (Exception e) {
           throw new OBException("Exception when creating UIDefinition for reference " + reference,
               e);