# HG changeset patch
# User Asier Lostalé <asier.lostale@openbravo.com>
# Date 1357720650 -3600
# Node ID 3c47f8b2a8131f66fc15448a8205ca7009ea385e
# Parent  3a694aaa93e31bb495daa22973c018a62b0a3d49
fixed bug 22764: cannot open any window

It was failing because of lazy initialization when OBViewUtil was
invoked before opening any window.

diff -r 3a694aaa93e3 -r 3c47f8b2a813 modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFieldHandler.java
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFieldHandler.java	Mon Dec 17 13:22:07 2012 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFieldHandler.java	Wed Jan 09 09:37:30 2013 +0100
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2011-2012 Openbravo SLU
+ * All portions are Copyright (C) 2011-2013 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -529,9 +529,11 @@
     }
 
     public OBViewFieldAudit(String type, Element element) {
+      // force reload of element as if it was previously loaded but its children were not touched,
+      // lazy initialization fails
+      this.element = OBDal.getInstance().get(Element.class, element.getId());
+
       name = type;
-      this.element = element;
-
       if (type.endsWith("By")) {
         // User search
         refType = "30";
