Merge stable changesets from int to main
authorRM packaging bot <staff.rm@openbravo.com>
Tue, 19 Jan 2010 01:39:32 +0100
changeset 5992 61ac33e4395d
parent 5926 2da2fd293de1 (current diff)
parent 5813 9027e387940b (diff)
child 5993 7f3a35240cf9
Merge stable changesets from int to main
src-db/database/sourcedata/AD_MESSAGE.xml
src-db/database/sourcedata/AD_PROCESS.xml
--- a/src-core/src/org/openbravo/base/HttpBaseServlet.java	Fri Jan 15 12:13:55 2010 +0100
+++ b/src-core/src/org/openbravo/base/HttpBaseServlet.java	Tue Jan 19 01:39:32 2010 +0100
@@ -15,6 +15,7 @@
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.io.OutputStream;
 import java.io.StringReader;
 import java.rmi.Naming;
 import java.sql.CallableStatement;
@@ -550,16 +551,16 @@
   }
 
   /**
-   * Renders the FO input source into a PDF file which is then written directly to the response to
-   * the user.
+   * Renders the FO input source into a PDF file which is then written directly to OutputStream.
    * 
    * @param strFo
    *          FO source string for generating the PDF.
-   * @param response
-   *          HttpServletResponse object to which the PDF will be rendered to.
+   * @param out
+   *          OutputStream object to which the PDF will be rendered to.
    * @throws ServletException
    */
-  protected void renderFO(String strFo, HttpServletResponse response) throws ServletException {
+
+  protected void renderFO(String strFo, OutputStream out) throws ServletException {
     // Check validity of the certificate
     // Create a trust manager that does not validate certificate chains
     TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
@@ -604,84 +605,85 @@
           org.apache.fop.apps.Options options = new org.apache.fop.apps.Options(fopFile);
         }
       }
-      strFo = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + strFo;
+
+      final String foTemplate = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + strFo;
 
       if ((globalParameters.strServidorRenderFo == null)
           || (globalParameters.strServidorRenderFo.equals(""))) {
+
         if (log4j.isDebugEnabled())
           log4j.debug(strFo);
-        StringReader sr = new StringReader(strFo);
+
+        StringReader sr = new StringReader(foTemplate);
+
         if (log4j.isDebugEnabled())
           log4j.debug(sr.toString());
+
         InputSource inputFO = new InputSource(sr);
 
-        // log4j.info("Beginning of ByteArrayOutputStream");
-        if (log4j.isDebugEnabled())
-          log4j.debug("Beginning of response.setContentType");
-        response.setContentType("application/pdf; charset=UTF-8");
         if (log4j.isDebugEnabled())
           log4j.debug("Beginning of driver");
+
         Driver driver = new Driver();
         driver.setLogger(globalParameters.getFopLogger());
         driver.setRenderer(Driver.RENDER_PDF);
         driver.setInputSource(inputFO);
 
-        // ByteArrayOutputStream out = new ByteArrayOutputStream();
-        driver.setOutputStream(response.getOutputStream());
+        driver.setOutputStream(out);
 
         if (log4j.isDebugEnabled())
           log4j.debug("driver.run()");
+
         driver.run();
-        /*
-         * log4j.info("Beginning of out.toByteArray()"); byte[] content = out.toByteArray();
-         * log4j.info("Beginning of response.setContentLength");
-         * response.setContentLength(content.length);log4j.info(
-         * "Beginning of response.getOutputStream().write(content)");
-         */
-        /*
-         * int incr = 1000; for (int i=0;i<content.length;i+=incr) { int end =
-         * ((content.length<(i+incr))?content.length-i:incr);
-         * response.getOutputStream().write(content, i, end); response.getOutputStream().flush(); }
-         */
-        /*
-         * response.getOutputStream().write(content);
-         * log4j.info("Beginning of response.getOutputStream().flush()" );
-         * response.getOutputStream().flush();
-         */
+
         if (log4j.isDebugEnabled())
           log4j.debug("End of renderFO");
-        response.getOutputStream().flush();
-        response.getOutputStream().close();
+
         sr.close();
         driver.reset();
         driver = null;
       } else {
-        response.setContentType("application/pdf; charset=UTF-8");
+
         RenderFoI render = (RenderFoI) Naming.lookup("rmi://"
             + globalParameters.strServidorRenderFo + "/RenderFo");
 
         byte[] content = render.computeRenderFo(strFo);
-        response.setContentLength(content.length);
-        /*
-         * int incr = 1000; for (int i=0;i<content.length;i+=incr) { int end =
-         * ((content.length<(i+incr))?content.length-i:incr);
-         * response.getOutputStream().write(content, i, end); response.getOutputStream().flush(); }
-         */
-        response.getOutputStream().write(content);
-        response.getOutputStream().flush();
+        out.write(content);
+        out.flush();
       }
     } catch (java.lang.IllegalStateException il) {
       return;
     } catch (Exception ex) {
-      try {
-        response.getOutputStream().flush();
-      } catch (Exception ignored) {
-      }
-      throw new ServletException(ex);
+      throw new ServletException(ex.getMessage(), ex);
     }
   }
 
   /**
+   * Renders a PDF directly into a HttpServletResponse. <b>NOTE:</b> If you use this method the
+   * 'loading' pop-up window will not be closed.
+   * 
+   * @param strFo
+   * @param out
+   * @throws ServletException
+   */
+  protected void renderFO(String strFo, HttpServletResponse response) throws ServletException {
+
+    try {
+
+      response.setContentType("application/pdf; charset=UTF-8");
+
+      renderFO(strFo, response.getOutputStream());
+
+      response.getOutputStream().flush();
+      response.getOutputStream().close();
+
+    } catch (Exception ex) {
+      throw new ServletException(ex.getMessage(), ex);
+    }
+
+  }
+
+  /**
    * Returns an instance of the xerces XML parser.
    * 
    * @return XMLReader object with the parser instance.
--- a/src-db/database/model/functions/C_INVOICE_POST.xml	Fri Jan 15 12:13:55 2010 +0100
+++ b/src-db/database/model/functions/C_INVOICE_POST.xml	Tue Jan 19 01:39:32 2010 +0100
@@ -231,8 +231,7 @@
     --* There are invoice lines
     --* There are tax lines
     --* There are both invoice and tax lines 
-    IF((v_DocStatus='DR' AND v_DocAction='CO')
-       OR (v_DocStatus='CO' AND v_DocAction='RE')) THEN
+    IF((v_DocStatus='DR' AND v_DocAction='CO')) THEN
           SELECT COUNT(*)
           INTO V_InvoiceLines_count
           FROM C_INVOICE
--- a/src-db/database/model/functions/C_ORDER_POST1.xml	Fri Jan 15 12:13:55 2010 +0100
+++ b/src-db/database/model/functions/C_ORDER_POST1.xml	Tue Jan 19 01:39:32 2010 +0100
@@ -37,6 +37,7 @@
   -- Parameter
   TYPE RECORD IS REF CURSOR;
     Cur_Parameter RECORD;
+    Cur_Order RECORD;
     -- Record Info
     v_Client_ID VARCHAR2(32);
     v_Org_ID VARCHAR2(32);
@@ -1286,7 +1287,18 @@
     END IF;
   END IF;
   -- We are done with standard sales orders
-  IF(v_DocAction IN('CO', 'CL', 'VO') AND v_DocSubTypeSO='SO') THEN
+IF (v_DocSubTypeSO = 'RM') THEN
+
+	FOR Cur_Order IN( SELECT ol.qtyordered from C_order o,C_orderline ol
+      where o.C_Order_ID = v_Record_ID
+      AND ol.C_Order_ID = o.C_Order_ID)
+	LOOP
+		IF (Cur_Order.qtyordered >0) THEN 
+			RAISE_APPLICATION_ERROR(-20000, '@ReturnMaterialOrderType@') ;
+		END IF;
+	END LOOP;
+	END IF;
+  IF(v_DocAction IN('CO', 'CL', 'VO') AND v_DocSubTypeSO IN('SO','RM')) THEN
     UPDATE C_ORDER
       SET DocStatus='CO',
       DocAction='--',
--- a/src-db/database/model/functions/M_INOUT_CREATE.xml	Fri Jan 15 12:13:55 2010 +0100
+++ b/src-db/database/model/functions/M_INOUT_CREATE.xml	Tue Jan 19 01:39:32 2010 +0100
@@ -34,7 +34,7 @@
   * parts created by ComPiere are Copyright (C) ComPiere, Inc.;
   * All Rights Reserved.
   * Contributor(s): Openbravo SL
-  * Contributions are Copyright (C) 2001-2009 Openbravo, S.L.
+  * Contributions are Copyright (C) 2001-2010 Openbravo, S.L.
   *
   * Specifically, this derivative work is based upon the following Compiere
   * file and version.
@@ -318,7 +318,7 @@
               (p_InOut_ID, Cur_Order.C_Order_ID, Cur_Order.IsSOTrx, Cur_Order.AD_Client_ID,
               Cur_Order.AD_Org_ID, 'Y', now(), '0',
               now(), '0', v_DocumentNo, v_DocType_ID,
-              Cur_Order.Description, 'N', 'C-', now(),
+              Cur_Order.Description, 'N', 'C-', Cur_Order.DATEORDERED,
               now(), Cur_Order.C_BPartner_ID, Cur_Order.C_BPartner_Location_ID, Cur_Order.AD_User_ID,
               Cur_Order.M_Warehouse_ID, Cur_Order.POReference, Cur_Order.DateOrdered, Cur_Order.DeliveryRule,
               Cur_Order.FreightCostRule, Cur_Order.FreightAmt, Cur_Order.C_Project_ID, Cur_Order.C_Activity_ID,
@@ -747,7 +747,7 @@
   ELSE
     RAISE;
   END IF;
-  p_InOut_ID:=0; -- Error Indicator
+  p_InOut_ID:='0'; -- Error Indicator
   RETURN;
 END M_INOUT_CREATE
 ]]></body>
--- a/src-db/database/model/functions/M_INOUT_POST.xml	Fri Jan 15 12:13:55 2010 +0100
+++ b/src-db/database/model/functions/M_INOUT_POST.xml	Tue Jan 19 01:39:32 2010 +0100
@@ -22,7 +22,7 @@
   * parts created by ComPiere are Copyright (C) ComPiere, Inc.;
   * All Rights Reserved.
   * Contributor(s): Openbravo SL
-  * Contributions are Copyright (C) 2001-2009 Openbravo, S.L.
+  * Contributions are Copyright (C) 2001-2010 Openbravo, S.L.
   *
   * Specifically, this derivative work is based upon the following Compiere
   * file and version.
@@ -117,154 +117,162 @@
     ELSE
       DBMS_OUTPUT.PUT_LINE('--<<M_InOut_Post>>') ;
       v_Record_ID:=p_InOut_ID;
+      SELECT count(*)
+        INTO v_Count
+        FROM M_InOut
+        WHERE M_InOut_ID=v_Record_ID;
+      IF v_Count=0 THEN
+        FINISH_PROCESS:=true;
+      END IF;
     END IF;
   BEGIN --BODY
-  	SELECT AD_Client_ID, AD_Org_ID, CreatedBy, C_DocType_ID, DateAcct
-      INTO v_AD_Client_ID, v_AD_Org_ID, v_User, v_DocType_ID, v_DateAcct
-      FROM M_InOut
-      WHERE M_InOut_ID=v_Record_ID;
-    SELECT count(*)
-    INTO v_Count
-    FROM AD_CLIENTINFO
-    WHERE AD_CLIENT_ID=v_AD_Client_ID
-      AND CHECKINOUTORG='Y';
-    IF v_Count>0 THEN
-      v_ResultStr:='CheckingRestrictions - M_INOUT ORG IS IN C_BPARTNER ORG TREE';
+  	IF(NOT FINISH_PROCESS) THEN
+      SELECT AD_Client_ID, AD_Org_ID, CreatedBy, C_DocType_ID, DateAcct
+        INTO v_AD_Client_ID, v_AD_Org_ID, v_User, v_DocType_ID, v_DateAcct
+        FROM M_InOut
+        WHERE M_InOut_ID=v_Record_ID;
       SELECT count(*)
       INTO v_Count
-      FROM M_InOut m,
-        C_BPartner bp
-      WHERE m.M_InOut_ID=v_Record_ID
-        AND m.C_BPARTNER_ID=bp.C_BPARTNER_ID
-        AND AD_IsOrgIncluded(m.AD_ORG_ID, bp.AD_ORG_ID, bp.AD_CLIENT_ID)=-1;
+      FROM AD_CLIENTINFO
+      WHERE AD_CLIENT_ID=v_AD_Client_ID
+        AND CHECKINOUTORG='Y';
       IF v_Count>0 THEN
-        RAISE_APPLICATION_ERROR(-20000, '@NotCorrectOrgBpartnerInout@') ;
+        v_ResultStr:='CheckingRestrictions - M_INOUT ORG IS IN C_BPARTNER ORG TREE';
+        SELECT count(*)
+        INTO v_Count
+        FROM M_InOut m,
+          C_BPartner bp
+        WHERE m.M_InOut_ID=v_Record_ID
+          AND m.C_BPARTNER_ID=bp.C_BPARTNER_ID
+          AND AD_IsOrgIncluded(m.AD_ORG_ID, bp.AD_ORG_ID, bp.AD_CLIENT_ID)=-1;
+        IF v_Count>0 THEN
+          RAISE_APPLICATION_ERROR(-20000, '@NotCorrectOrgBpartnerInout@') ;
+        END IF;
       END IF;
-    END IF;
-    IF(NOT FINISH_PROCESS) THEN
-      v_ResultStr:='CheckingRestrictions';
-      SELECT COUNT(*)
-   INTO v_Count
-   FROM C_DocType,
-        M_InOut M
-   WHERE M_Inout_ID = v_Record_ID
-     AND C_DocType.DocBaseType IN ('MMR', 'MMS')
-    AND C_DocType.IsSOTrx=M.IsSOTrx
-    AND AD_ISORGINCLUDED(m.AD_Org_ID,C_DocType.AD_Org_ID, m.AD_Client_ID) <> -1
-     AND M.C_DOCTYPE_ID=C_DocType.C_DOCTYPE_ID;
-      IF v_Count=0 THEN
-        RAISE_APPLICATION_ERROR(-20000, '@NotCorrectOrgDoctypeShipment@') ;
+      
+     v_ResultStr:='CheckingRestrictions';
+     SELECT COUNT(*)
+     INTO v_Count
+     FROM C_DocType,
+          M_InOut M
+     WHERE M_Inout_ID = v_Record_ID
+       AND C_DocType.DocBaseType IN ('MMR', 'MMS')
+      AND C_DocType.IsSOTrx=M.IsSOTrx
+      AND AD_ISORGINCLUDED(m.AD_Org_ID,C_DocType.AD_Org_ID, m.AD_Client_ID) <> -1
+       AND M.C_DOCTYPE_ID=C_DocType.C_DOCTYPE_ID;
+        IF v_Count=0 THEN
+          RAISE_APPLICATION_ERROR(-20000, '@NotCorrectOrgDoctypeShipment@') ;
+        END IF;
+        SELECT COUNT(*), MAX(M.line)
+        INTO v_Count, v_line
+        FROM M_InOutLine M,
+          M_Product P
+        WHERE M.M_PRODUCT_ID=P.M_PRODUCT_ID
+          AND P.M_ATTRIBUTESET_ID IS NOT NULL
+          AND P.M_ATTRIBUTESETINSTANCE_ID IS NULL
+          AND COALESCE(M.M_ATTRIBUTESETINSTANCE_ID, '0') = '0'
+          AND M.M_INOUT_ID=v_Record_ID;
+        IF v_Count<>0 THEN
+          RAISE_APPLICATION_ERROR(-20000, '@Inline@ '||v_line||' '||'@productWithoutAttributeSet@') ;
+        END IF;
+        SELECT COUNT(*), MAX(M.line)
+        INTO v_Count, v_Line
+        FROM M_InOut I,
+          M_InOutLine M,
+          M_AttributeSetInstance P
+        WHERE I.M_InOut_ID=M.M_InOut_ID
+          AND M.M_AttributeSetInstance_ID=P.M_AttributeSetInstance_ID
+          AND P.ISLOCKED='Y'
+          AND I.ISSOTRX='Y'
+          AND I.M_INOUT_ID=v_Record_ID;
+        IF v_Count<>0 THEN
+          RAISE_APPLICATION_ERROR(-20000, '@Inline@'||v_line||' '||'@lockedProduct@') ;
+        END IF;
+      -- check inout line instance location
+        SELECT COUNT(*), MAX(M.line)
+        INTO v_Count, v_Line
+        FROM M_InOutLine M,
+          M_Product P
+        WHERE M.M_InOut_ID=v_Record_ID
+          AND M.M_Locator_ID IS NULL
+          AND p.m_product_id = m.m_product_id
+          AND p.isstocked = 'Y'
+          AND p.producttype = 'I';
+        IF v_Count <> 0 THEN
+          RAISE_APPLICATION_ERROR(-20000, '@Inline@'||v_line||' '||'@InoutLineWithoutLocator@') ;
+        END IF;	  
+      
+        -- Process Shipments
+  
+     -- Set org lines like the header
+       UPDATE M_INOUTLINE
+        SET AD_ORG_ID = (SELECT AD_ORG_ID FROM M_INOUT WHERE M_INOUT_ID = v_Record_ID)
+      WHERE M_INOUT_ID = v_Record_ID;
+      
+      -- Check the header belongs to a organization where transactions are posible and ready to use
+      SELECT AD_Org.IsReady, Ad_OrgType.IsTransactionsAllowed
+      INTO v_is_ready, v_is_tr_allow
+      FROM M_INOUT, AD_Org, AD_OrgType
+      WHERE AD_Org.AD_Org_ID=M_INOUT.AD_Org_ID
+      AND AD_Org.AD_OrgType_ID=AD_OrgType.AD_OrgType_ID
+      AND M_INOUT.M_INOUT_ID=v_Record_ID;
+      IF (v_is_ready='N') THEN
+        RAISE_APPLICATION_ERROR(-20000, '@OrgHeaderNotReady@');
       END IF;
-      SELECT COUNT(*), MAX(M.line)
-      INTO v_Count, v_line
-      FROM M_InOutLine M,
-        M_Product P
-      WHERE M.M_PRODUCT_ID=P.M_PRODUCT_ID
-        AND P.M_ATTRIBUTESET_ID IS NOT NULL
-        AND P.M_ATTRIBUTESETINSTANCE_ID IS NULL
-        AND COALESCE(M.M_ATTRIBUTESETINSTANCE_ID, '0') = '0'
-        AND M.M_INOUT_ID=v_Record_ID;
-      IF v_Count<>0 THEN
-        RAISE_APPLICATION_ERROR(-20000, '@Inline@ '||v_line||' '||'@productWithoutAttributeSet@') ;
+      IF (v_is_tr_allow='N') THEN
+        RAISE_APPLICATION_ERROR(-20000, '@OrgHeaderNotTransAllowed@');
       END IF;
-      SELECT COUNT(*), MAX(M.line)
-      INTO v_Count, v_Line
-      FROM M_InOut I,
-        M_InOutLine M,
-        M_AttributeSetInstance P
-      WHERE I.M_InOut_ID=M.M_InOut_ID
-        AND M.M_AttributeSetInstance_ID=P.M_AttributeSetInstance_ID
-        AND P.ISLOCKED='Y'
-        AND I.ISSOTRX='Y'
-        AND I.M_INOUT_ID=v_Record_ID;
-      IF v_Count<>0 THEN
-        RAISE_APPLICATION_ERROR(-20000, '@Inline@'||v_line||' '||'@lockedProduct@') ;
+        
+      SELECT AD_ORG_CHK_DOCUMENTS('M_INOUT', 'M_INOUTLINE', v_Record_ID, 'M_INOUT_ID', 'M_INOUT_ID') INTO v_is_included FROM dual;
+      IF (v_is_included=-1) THEN
+        RAISE_APPLICATION_ERROR(-20000, '@LinesAndHeaderDifferentLEorBU@');
       END IF;
-	  -- check inout line instance location
-      SELECT COUNT(*), MAX(M.line)
-      INTO v_Count, v_Line
-      FROM M_InOutLine M,
-        M_Product P
-      WHERE M.M_InOut_ID=v_Record_ID
-		    AND M.M_Locator_ID IS NULL
-        AND p.m_product_id = m.m_product_id
-        AND p.isstocked = 'Y'
-        AND p.producttype = 'I';
-      IF v_Count <> 0 THEN
-        RAISE_APPLICATION_ERROR(-20000, '@Inline@'||v_line||' '||'@InoutLineWithoutLocator@') ;
-      END IF;	  
-	  
-      -- Process Shipments
-
-   -- Set org lines like the header
-     UPDATE M_INOUTLINE
-      SET AD_ORG_ID = (SELECT AD_ORG_ID FROM M_INOUT WHERE M_INOUT_ID = v_Record_ID)
-    WHERE M_INOUT_ID = v_Record_ID;
-    
-    -- Check the header belongs to a organization where transactions are posible and ready to use
-    SELECT AD_Org.IsReady, Ad_OrgType.IsTransactionsAllowed
-    INTO v_is_ready, v_is_tr_allow
-    FROM M_INOUT, AD_Org, AD_OrgType
-    WHERE AD_Org.AD_Org_ID=M_INOUT.AD_Org_ID
-    AND AD_Org.AD_OrgType_ID=AD_OrgType.AD_OrgType_ID
-    AND M_INOUT.M_INOUT_ID=v_Record_ID;
-    IF (v_is_ready='N') THEN
-      RAISE_APPLICATION_ERROR(-20000, '@OrgHeaderNotReady@');
-    END IF;
-    IF (v_is_tr_allow='N') THEN
-      RAISE_APPLICATION_ERROR(-20000, '@OrgHeaderNotTransAllowed@');
-    END IF;
       
-    SELECT AD_ORG_CHK_DOCUMENTS('M_INOUT', 'M_INOUTLINE', v_Record_ID, 'M_INOUT_ID', 'M_INOUT_ID') INTO v_is_included FROM dual;
-    IF (v_is_included=-1) THEN
-      RAISE_APPLICATION_ERROR(-20000, '@LinesAndHeaderDifferentLEorBU@');
-    END IF;
-    
-    -- Check the period control is opened (only if it is legal entity with accounting)
-    -- Gets the BU or LE of the document
-    SELECT AD_GET_DOC_LE_BU('M_INOUT', v_Record_ID, 'M_INOUT_ID', 'LE')
-    INTO v_org_bule_id
-    FROM DUAL;
-    
-    SELECT AD_OrgType.IsAcctLegalEntity
-    INTO v_isacctle
-    FROM AD_OrgType, AD_Org
-    WHERE AD_Org.AD_OrgType_ID = AD_OrgType.AD_OrgType_ID
-    AND AD_Org.AD_Org_ID=v_org_bule_id;
-    
-    IF (v_isacctle='Y') THEN    
-      SELECT C_CHK_OPEN_PERIOD(v_AD_Org_ID, v_DateAcct, NULL, v_DocType_ID) 
-      INTO v_available_period
+      -- Check the period control is opened (only if it is legal entity with accounting)
+      -- Gets the BU or LE of the document
+      SELECT AD_GET_DOC_LE_BU('M_INOUT', v_Record_ID, 'M_INOUT_ID', 'LE')
+      INTO v_org_bule_id
       FROM DUAL;
       
-      IF (v_available_period<>1) THEN
-        RAISE_APPLICATION_ERROR(-20000, '@PeriodNotAvailable@');
-      END IF;
-    END IF;  
-
-      FOR Cur_InOut IN
-        (SELECT *
-        FROM M_INOUT
-        WHERE(M_InOut_ID=v_Record_ID
-          OR(v_Record_ID IS NULL
-          AND DocAction='CO'))
-          AND IsActive='Y'  FOR UPDATE
-        )
-      LOOP
-        DBMS_OUTPUT.PUT_LINE('Shipment_ID=' || Cur_InOut.M_InOut_ID || ', Doc=' || Cur_InOut.DocumentNo || ', Status=' || Cur_InOut.DocStatus || ', Action=' || Cur_InOut.DocAction) ;
-        v_ResultStr:='HeaderLoop';
-        /**
-        * Shipment not processed
-        */
-        IF(Cur_InOut.Processed='N' AND Cur_InOut.DocStatus='DR' AND Cur_InOut.DocAction='CO') THEN
-          -- For all active shipment lines
-          v_ResultStr:='HeaderLoop-1';
-          SELECT COUNT(*) INTO v_Aux
-			FROM M_InOutLine
-			WHERE M_InOut_ID = v_Record_ID;
-		  IF v_Aux=0 THEN
-			RAISE_APPLICATION_ERROR(-20000, '@ReceiptWithoutLines@');
-		  END IF;
+      SELECT AD_OrgType.IsAcctLegalEntity
+      INTO v_isacctle
+      FROM AD_OrgType, AD_Org
+      WHERE AD_Org.AD_OrgType_ID = AD_OrgType.AD_OrgType_ID
+      AND AD_Org.AD_Org_ID=v_org_bule_id;
+      
+      IF (v_isacctle='Y') THEN    
+        SELECT C_CHK_OPEN_PERIOD(v_AD_Org_ID, v_DateAcct, NULL, v_DocType_ID) 
+        INTO v_available_period
+        FROM DUAL;
+        
+        IF (v_available_period<>1) THEN
+          RAISE_APPLICATION_ERROR(-20000, '@PeriodNotAvailable@');
+        END IF;
+      END IF;  
+  
+        FOR Cur_InOut IN
+          (SELECT *
+          FROM M_INOUT
+          WHERE(M_InOut_ID=v_Record_ID
+            OR(v_Record_ID IS NULL
+            AND DocAction='CO'))
+            AND IsActive='Y'  FOR UPDATE
+          )
+        LOOP
+          DBMS_OUTPUT.PUT_LINE('Shipment_ID=' || Cur_InOut.M_InOut_ID || ', Doc=' || Cur_InOut.DocumentNo || ', Status=' || Cur_InOut.DocStatus || ', Action=' || Cur_InOut.DocAction) ;
+          v_ResultStr:='HeaderLoop';
+          /**
+          * Shipment not processed
+          */
+          IF(Cur_InOut.Processed='N' AND Cur_InOut.DocStatus='DR' AND Cur_InOut.DocAction='CO') THEN
+            -- For all active shipment lines
+            v_ResultStr:='HeaderLoop-1';
+            SELECT COUNT(*) INTO v_Aux
+        FROM M_InOutLine
+        WHERE M_InOut_ID = v_Record_ID;
+        IF v_Aux=0 THEN
+        RAISE_APPLICATION_ERROR(-20000, '@ReceiptWithoutLines@');
+        END IF;
           FOR Cur_InOutLine IN
             (SELECT *
             FROM M_INOUTLINE
--- a/src-db/database/model/functions/M_REQUISITION_CREATEPO.xml	Fri Jan 15 12:13:55 2010 +0100
+++ b/src-db/database/model/functions/M_REQUISITION_CREATEPO.xml	Tue Jan 19 01:39:32 2010 +0100
@@ -16,7 +16,7 @@
 * under the License.
 * The Original Code is Openbravo ERP.
 * The Initial Developer of the Original Code is Openbravo SL
-* All portions are Copyright (C) 2008-2009 Openbravo SL
+* All portions are Copyright (C) 2008-2010 Openbravo SL
 * All Rights Reserved.
 * Contributor(s):  ______________________________________.
 ************************************************************************/
@@ -219,14 +219,13 @@
       Ad_Sequence_Next('C_OrderLine', v_Client_ID, v_COrderLine_ID);
 
       SELECT pp.PRICELIST, pp.PRICELIMIT, pp.PRICESTD,
-             ROUND(COALESCE(Cur_Lines.PRICEACTUAL, M_GET_OFFERS_PRICE(TO_DATE(p_OrderDate), Cur_Lines.C_BPID, Cur_Lines.M_Product_ID, COALESCE(Cur_Lines.PRICEACTUAL, pp.PRICESTD), TO_NUMBER(Cur_Lines.QTY - Cur_Lines.ORDEREDQTY), Cur_Lines.PRICELIST_ID)), CUR.PRICEPRECISION),
-             ROUND((COALESCE(pp.PRICELIST, Cur_Lines.PRICELIST, Cur_Lines.PRICEACTUAL) - COALESCE(Cur_Lines.PRICEACTUAL, M_GET_OFFERS_PRICE(TO_DATE(p_OrderDate), Cur_Lines.C_BPID, Cur_Lines.M_Product_ID, COALESCE(Cur_Lines.PRICEACTUAL, pp.PRICESTD),TO_NUMBER(Cur_Lines.QTY - Cur_Lines.ORDEREDQTY), Cur_Lines.PRICELIST_ID)))/
-                 COALESCE(pp.PRICELIST, Cur_Lines.PRICELIST, Cur_Lines.PRICEACTUAL)*100,CUR.STDPRECISION)
+             ROUND(M_GET_OFFERS_PRICE(TO_DATE(p_OrderDate),Cur_Lines.C_BPID,Cur_Lines.M_Product_ID,COALESCE(Cur_Lines.PRICEACTUAL, pp.PRICESTD),Cur_Lines.QTY - Cur_Lines.ORDEREDQTY,Cur_Lines.PRICELIST_ID),CUR.PRICEPRECISION),
+             ROUND((pp.PRICELIST - pp.PRICESTD)/pp.PRICELIST*100,CUR.STDPRECISION)
         INTO v_PriceList, v_PriceLimit, v_PriceStd, v_PriceActual, v_Discount
       FROM
-        (SELECT COALESCE(MAX(M_PRODUCTPRICE.PRICELIST), Cur_Lines.PRICELIST, Cur_Lines.PRICEACTUAL) AS PRICELIST,
+        (SELECT COALESCE(Cur_Lines.PRICELIST, MAX(M_PRODUCTPRICE.PRICELIST), Cur_Lines.PRICEACTUAL) AS PRICELIST,
              COALESCE(MAX(M_PRODUCTPRICE.PRICELIMIT), Cur_Lines.PRICEACTUAL) AS PRICELIMIT,
-             COALESCE(MAX(M_PRODUCTPRICE.PRICESTD), Cur_Lines.PRICEACTUAL) AS PRICESTD
+             COALESCE(Cur_Lines.PRICEACTUAL, MAX(M_PRODUCTPRICE.PRICESTD)) AS PRICESTD
          FROM M_PRODUCTPRICE
          WHERE M_PRICELIST_VERSION_ID = M_GET_PRICELIST_VERSION(Cur_Lines.PRICELIST_ID, p_OrderDate)
            AND M_PRODUCT_ID = Cur_Lines.M_PRODUCT_ID) pp, (SELECT PRICEPRECISION, STDPRECISION FROM C_CURRENCY WHERE C_CURRENCY_ID = v_Currency_ID) CUR;
--- a/src-db/database/model/postscript-Oracle.sql	Fri Jan 15 12:13:55 2010 +0100
+++ b/src-db/database/model/postscript-Oracle.sql	Tue Jan 19 01:39:32 2010 +0100
@@ -818,6 +818,17 @@
 END;
 /-- END
 
+--Inserts role access for new register window
+--See issue:  https://issues.openbravo.com/view.php?id=11349
+BEGIN
+    INSERT INTO ad_form_access(ad_form_access_id, ad_form_id, ad_role_id,
+                               ad_client_id, ad_org_id, isactive, created,
+                               createdby, updated, updatedby, isreadwrite)
+    VALUES('41263F39F7614270808A955844B07A7F', '3D8AB0C824ED4C70ADE086D9CFE5DA1A', '0', '0', '0', 'Y', now(), '0', now(), '0', 'Y');
+EXCEPTION WHEN OTHERS THEN NULL;
+END;
+/-- END
+
 BEGIN
    EXECUTE IMMEDIATE 'alter trigger ad_tab_mod_trg disable';
 END;
--- a/src-db/database/model/postscript-PostgreSql.sql	Fri Jan 15 12:13:55 2010 +0100
+++ b/src-db/database/model/postscript-PostgreSql.sql	Tue Jan 19 01:39:32 2010 +0100
@@ -604,3 +604,37 @@
   LANGUAGE 'plpgsql' VOLATILE;
 SELECT pg_temp.insert_recipient();
 /-- END
+
+--Inserts role access for new register window
+--See issue:  https://issues.openbravo.com/view.php?id=11349
+CREATE OR REPLACE FUNCTION pg_temp.insert_register_form_access()
+  RETURNS void AS
+$BODY$ DECLARE
+/*************************************************************************
+* The contents of this file are subject to the Openbravo  Public  License
+* Version  1.0  (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 SL
+* All portions are Copyright (C) 2009 Openbravo SL
+* All Rights Reserved.
+* Contributor(s):  ______________________________________.
+************************************************************************/
+BEGIN
+  INSERT INTO ad_form_access(ad_form_access_id, ad_form_id, ad_role_id,
+                               ad_client_id, ad_org_id, isactive, created,
+                               createdby, updated, updatedby, isreadwrite)
+         VALUES('41263F39F7614270808A955844B07A7F', '3D8AB0C824ED4C70ADE086D9CFE5DA1A', '0', '0', '0', 'Y', now(), '0', now(), '0', 'Y');
+EXCEPTION
+WHEN OTHERS THEN
+--do nothing
+END;   $BODY$
+  LANGUAGE 'plpgsql' VOLATILE;
+SELECT pg_temp.insert_register_form_access();
+/-- END
--- a/src-db/database/sourcedata/AD_CALLOUT.xml	Fri Jan 15 12:13:55 2010 +0100
+++ b/src-db/database/sourcedata/AD_CALLOUT.xml	Tue Jan 19 01:39:32 2010 +0100
@@ -776,6 +776,15 @@
 <!--52415CD3A31640B8906555725299FED7-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--52415CD3A31640B8906555725299FED7--></AD_CALLOUT>
 
+<!--80DD3736B9EE42C5A0A793009F35C55A--><AD_CALLOUT>
+<!--80DD3736B9EE42C5A0A793009F35C55A-->  <AD_CALLOUT_ID><![CDATA[80DD3736B9EE42C5A0A793009F35C55A]]></AD_CALLOUT_ID>
+<!--80DD3736B9EE42C5A0A793009F35C55A-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--80DD3736B9EE42C5A0A793009F35C55A-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--80DD3736B9EE42C5A0A793009F35C55A-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--80DD3736B9EE42C5A0A793009F35C55A-->  <NAME><![CDATA[SL_ModuleCallout]]></NAME>
+<!--80DD3736B9EE42C5A0A793009F35C55A-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--80DD3736B9EE42C5A0A793009F35C55A--></AD_CALLOUT>
+
 <!--C252244131684EE28DB86DDFD278DB85--><AD_CALLOUT>
 <!--C252244131684EE28DB86DDFD278DB85-->  <AD_CALLOUT_ID><![CDATA[C252244131684EE28DB86DDFD278DB85]]></AD_CALLOUT_ID>
 <!--C252244131684EE28DB86DDFD278DB85-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_COLUMN.xml	Fri Jan 15 12:13:55 2010 +0100
+++ b/src-db/database/sourcedata/AD_COLUMN.xml	Tue Jan 19 01:39:32 2010 +0100
@@ -251571,6 +251571,7 @@
 <!--565E56DF64EA9042E040007F01002829-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
 <!--565E56DF64EA9042E040007F01002829-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
 <!--565E56DF64EA9042E040007F01002829-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--565E56DF64EA9042E040007F01002829-->  <AD_CALLOUT_ID><![CDATA[80DD3736B9EE42C5A0A793009F35C55A]]></AD_CALLOUT_ID>
 <!--565E56DF64EA9042E040007F01002829-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--565E56DF64EA9042E040007F01002829-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--565E56DF64EA9042E040007F01002829-->  <POSITION><![CDATA[14]]></POSITION>
@@ -251634,6 +251635,7 @@
 <!--565E56DF64EC9042E040007F01002829-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
 <!--565E56DF64EC9042E040007F01002829-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
 <!--565E56DF64EC9042E040007F01002829-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--565E56DF64EC9042E040007F01002829-->  <AD_CALLOUT_ID><![CDATA[80DD3736B9EE42C5A0A793009F35C55A]]></AD_CALLOUT_ID>
 <!--565E56DF64EC9042E040007F01002829-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--565E56DF64EC9042E040007F01002829-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--565E56DF64EC9042E040007F01002829-->  <POSITION><![CDATA[16]]></POSITION>
--- a/src-db/database/sourcedata/AD_FORM.xml	Fri Jan 15 12:13:55 2010 +0100
+++ b/src-db/database/sourcedata/AD_FORM.xml	Tue Jan 19 01:39:32 2010 +0100
@@ -392,6 +392,18 @@
 <!--25C886DA08E947F29AAC1D30D8B753A1-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--25C886DA08E947F29AAC1D30D8B753A1--></AD_FORM>
 
+<!--3D8AB0C824ED4C70ADE086D9CFE5DA1A--><AD_FORM>
+<!--3D8AB0C824ED4C70ADE086D9CFE5DA1A-->  <AD_FORM_ID><![CDATA[3D8AB0C824ED4C70ADE086D9CFE5DA1A]]></AD_FORM_ID>
+<!--3D8AB0C824ED4C70ADE086D9CFE5DA1A-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--3D8AB0C824ED4C70ADE086D9CFE5DA1A-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--3D8AB0C824ED4C70ADE086D9CFE5DA1A-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--3D8AB0C824ED4C70ADE086D9CFE5DA1A-->  <NAME><![CDATA[Register]]></NAME>
+<!--3D8AB0C824ED4C70ADE086D9CFE5DA1A-->  <DESCRIPTION><![CDATA[Register your installation of Openbravo ERP in order to receive development and commercial updates and information]]></DESCRIPTION>
+<!--3D8AB0C824ED4C70ADE086D9CFE5DA1A-->  <ACCESSLEVEL><![CDATA[4]]></ACCESSLEVEL>
+<!--3D8AB0C824ED4C70ADE086D9CFE5DA1A-->  <CLASSNAME><![CDATA[org.openbravo.erpCommon.utility.Register]]></CLASSNAME>
+<!--3D8AB0C824ED4C70ADE086D9CFE5DA1A-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--3D8AB0C824ED4C70ADE086D9CFE5DA1A--></AD_FORM>
+
 <!--8D6282279F464B1696B0EE3E23023B65--><AD_FORM>
 <!--8D6282279F464B1696B0EE3E23023B65-->  <AD_FORM_ID><![CDATA[8D6282279F464B1696B0EE3E23023B65]]></AD_FORM_ID>
 <!--8D6282279F464B1696B0EE3E23023B65-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_MENU.xml	Fri Jan 15 12:13:55 2010 +0100
+++ b/src-db/database/sourcedata/AD_MENU.xml	Tue Jan 19 01:39:32 2010 +0100
@@ -3443,7 +3443,7 @@
 <!--800090-->  <AD_MENU_ID><![CDATA[800090]]></AD_MENU_ID>
 <!--800090-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
 <!--800090-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--800090-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--800090-->  <ISACTIVE><![CDATA[N]]></ISACTIVE>
 <!--800090-->  <NAME><![CDATA[Generate 347 Model]]></NAME>
 <!--800090-->  <DESCRIPTION><![CDATA[Generate model 347]]></DESCRIPTION>
 <!--800090-->  <ISSUMMARY><![CDATA[N]]></ISSUMMARY>
@@ -5313,8 +5313,8 @@
 <!--1005400002-->  <NAME><![CDATA[Register]]></NAME>
 <!--1005400002-->  <DESCRIPTION><![CDATA[Register your installation of Openbravo ERP in order to receive development and commercial updates and information]]></DESCRIPTION>
 <!--1005400002-->  <ISSUMMARY><![CDATA[N]]></ISSUMMARY>
-<!--1005400002-->  <ACTION><![CDATA[L]]></ACTION>
-<!--1005400002-->  <URL><![CDATA[http://www.openbravo.com/embedreg/form]]></URL>
+<!--1005400002-->  <ACTION><![CDATA[X]]></ACTION>
+<!--1005400002-->  <AD_FORM_ID><![CDATA[3D8AB0C824ED4C70ADE086D9CFE5DA1A]]></AD_FORM_ID>
 <!--1005400002-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--1005400002--></AD_MENU>
 
--- a/src-db/database/sourcedata/AD_MESSAGE.xml	Fri Jan 15 12:13:55 2010 +0100
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml	Tue Jan 19 01:39:32 2010 +0100
@@ -29613,6 +29613,17 @@
 <!--0C093B834C3948E1B8D84E54FC6B284E-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--0C093B834C3948E1B8D84E54FC6B284E--></AD_MESSAGE>
 
+<!--0C16030DD5DF4F75AB032C4A8B6CF70B--><AD_MESSAGE>
+<!--0C16030DD5DF4F75AB032C4A8B6CF70B-->  <AD_MESSAGE_ID><![CDATA[0C16030DD5DF4F75AB032C4A8B6CF70B]]></AD_MESSAGE_ID>
+<!--0C16030DD5DF4F75AB032C4A8B6CF70B-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--0C16030DD5DF4F75AB032C4A8B6CF70B-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--0C16030DD5DF4F75AB032C4A8B6CF70B-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--0C16030DD5DF4F75AB032C4A8B6CF70B-->  <VALUE><![CDATA[ReturnMaterialOrderType]]></VALUE>
+<!--0C16030DD5DF4F75AB032C4A8B6CF70B-->  <MSGTEXT><![CDATA[Return Material order lines require negative quantities.]]></MSGTEXT>
+<!--0C16030DD5DF4F75AB032C4A8B6CF70B-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--0C16030DD5DF4F75AB032C4A8B6CF70B-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--0C16030DD5DF4F75AB032C4A8B6CF70B--></AD_MESSAGE>
+
 <!--0C56CA075AAA4D6D8BE7A4377D0AC0EF--><AD_MESSAGE>
 <!--0C56CA075AAA4D6D8BE7A4377D0AC0EF-->  <AD_MESSAGE_ID><![CDATA[0C56CA075AAA4D6D8BE7A4377D0AC0EF]]></AD_MESSAGE_ID>
 <!--0C56CA075AAA4D6D8BE7A4377D0AC0EF-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -30692,6 +30703,19 @@
 <!--5BBAF581EEC94A11BB175D2398CE0B76-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--5BBAF581EEC94A11BB175D2398CE0B76--></AD_MESSAGE>
 
+<!--5D3624FE019649CCB3B5900F32E59E17--><AD_MESSAGE>
+<!--5D3624FE019649CCB3B5900F32E59E17-->  <AD_MESSAGE_ID><![CDATA[5D3624FE019649CCB3B5900F32E59E17]]></AD_MESSAGE_ID>
+<!--5D3624FE019649CCB3B5900F32E59E17-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--5D3624FE019649CCB3B5900F32E59E17-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--5D3624FE019649CCB3B5900F32E59E17-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--5D3624FE019649CCB3B5900F32E59E17-->  <VALUE><![CDATA[IDENTIFICATION_FAILURE_MSG]]></VALUE>
+<!--5D3624FE019649CCB3B5900F32E59E17-->  <MSGTEXT><![CDATA[Please enter your username and password.
+You must also ensure that your browser accepts cookies.
+Press back to return.]]></MSGTEXT>
+<!--5D3624FE019649CCB3B5900F32E59E17-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--5D3624FE019649CCB3B5900F32E59E17-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--5D3624FE019649CCB3B5900F32E59E17--></AD_MESSAGE>
+
 <!--5DDBAC99880F4F159204247F691227DB--><AD_MESSAGE>
 <!--5DDBAC99880F4F159204247F691227DB-->  <AD_MESSAGE_ID><![CDATA[5DDBAC99880F4F159204247F691227DB]]></AD_MESSAGE_ID>
 <!--5DDBAC99880F4F159204247F691227DB-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -31967,6 +31991,17 @@
 <!--EA8C3BCA062B4BB687AE2A2AAE4E32EE-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--EA8C3BCA062B4BB687AE2A2AAE4E32EE--></AD_MESSAGE>
 
+<!--EB21629341AC4F7CB3F7EE16BCA24E4D--><AD_MESSAGE>
+<!--EB21629341AC4F7CB3F7EE16BCA24E4D-->  <AD_MESSAGE_ID><![CDATA[EB21629341AC4F7CB3F7EE16BCA24E4D]]></AD_MESSAGE_ID>
+<!--EB21629341AC4F7CB3F7EE16BCA24E4D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--EB21629341AC4F7CB3F7EE16BCA24E4D-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--EB21629341AC4F7CB3F7EE16BCA24E4D-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--EB21629341AC4F7CB3F7EE16BCA24E4D-->  <VALUE><![CDATA[MultipleDevelopmentTemplates]]></VALUE>
+<!--EB21629341AC4F7CB3F7EE16BCA24E4D-->  <MSGTEXT><![CDATA[template is in development. Only one template can be in development at the same time. Current template has been set not in developemnt.]]></MSGTEXT>
+<!--EB21629341AC4F7CB3F7EE16BCA24E4D-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--EB21629341AC4F7CB3F7EE16BCA24E4D-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--EB21629341AC4F7CB3F7EE16BCA24E4D--></AD_MESSAGE>
+
 <!--ED94DA7D967E401B93DDFFE86C9715A9--><AD_MESSAGE>
 <!--ED94DA7D967E401B93DDFFE86C9715A9-->  <AD_MESSAGE_ID><![CDATA[ED94DA7D967E401B93DDFFE86C9715A9]]></AD_MESSAGE_ID>
 <!--ED94DA7D967E401B93DDFFE86C9715A9-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -32177,6 +32212,17 @@
 <!--FE74EA5C061C418C8A807FB4AF423C1D-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--FE74EA5C061C418C8A807FB4AF423C1D--></AD_MESSAGE>
 
+<!--FE88E1D0FB204477983A77FE42C1297A--><AD_MESSAGE>
+<!--FE88E1D0FB204477983A77FE42C1297A-->  <AD_MESSAGE_ID><![CDATA[FE88E1D0FB204477983A77FE42C1297A]]></AD_MESSAGE_ID>
+<!--FE88E1D0FB204477983A77FE42C1297A-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--FE88E1D0FB204477983A77FE42C1297A-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--FE88E1D0FB204477983A77FE42C1297A-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--FE88E1D0FB204477983A77FE42C1297A-->  <VALUE><![CDATA[IDENTIFICATION_FAILURE_TITLE]]></VALUE>
+<!--FE88E1D0FB204477983A77FE42C1297A-->  <MSGTEXT><![CDATA[Identification failure.Try again.]]></MSGTEXT>
+<!--FE88E1D0FB204477983A77FE42C1297A-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--FE88E1D0FB204477983A77FE42C1297A-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--FE88E1D0FB204477983A77FE42C1297A--></AD_MESSAGE>
+
 <!--FEC463B86D204D7982180B6C134F1E8A--><AD_MESSAGE>
 <!--FEC463B86D204D7982180B6C134F1E8A-->  <AD_MESSAGE_ID><![CDATA[FEC463B86D204D7982180B6C134F1E8A]]></AD_MESSAGE_ID>
 <!--FEC463B86D204D7982180B6C134F1E8A-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_MODEL_OBJECT.xml	Fri Jan 15 12:13:55 2010 +0100
+++ b/src-db/database/sourcedata/AD_MODEL_OBJECT.xml	Tue Jan 19 01:39:32 2010 +0100
@@ -17513,6 +17513,18 @@
 <!--73A0528DBCE1F38BE040007F01011E2B-->  <OBJECT_TYPE><![CDATA[S]]></OBJECT_TYPE>
 <!--73A0528DBCE1F38BE040007F01011E2B--></AD_MODEL_OBJECT>
 
+<!--7AEA3C790893370FE040007F01013A5F--><AD_MODEL_OBJECT>
+<!--7AEA3C790893370FE040007F01013A5F-->  <AD_MODEL_OBJECT_ID><![CDATA[7AEA3C790893370FE040007F01013A5F]]></AD_MODEL_OBJECT_ID>
+<!--7AEA3C790893370FE040007F01013A5F-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--7AEA3C790893370FE040007F01013A5F-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--7AEA3C790893370FE040007F01013A5F-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--7AEA3C790893370FE040007F01013A5F-->  <ACTION><![CDATA[C]]></ACTION>
+<!--7AEA3C790893370FE040007F01013A5F-->  <CLASSNAME><![CDATA[org.openbravo.erpCommon.ad_callouts.SL_ModuleCallout]]></CLASSNAME>
+<!--7AEA3C790893370FE040007F01013A5F-->  <ISDEFAULT><![CDATA[Y]]></ISDEFAULT>
+<!--7AEA3C790893370FE040007F01013A5F-->  <AD_CALLOUT_ID><![CDATA[80DD3736B9EE42C5A0A793009F35C55A]]></AD_CALLOUT_ID>
+<!--7AEA3C790893370FE040007F01013A5F-->  <OBJECT_TYPE><![CDATA[S]]></OBJECT_TYPE>
+<!--7AEA3C790893370FE040007F01013A5F--></AD_MODEL_OBJECT>
+
 <!--88420DFF1C6D48A18800FB91A91362AA--><AD_MODEL_OBJECT>
 <!--88420DFF1C6D48A18800FB91A91362AA-->  <AD_MODEL_OBJECT_ID><![CDATA[88420DFF1C6D48A18800FB91A91362AA]]></AD_MODEL_OBJECT_ID>
 <!--88420DFF1C6D48A18800FB91A91362AA-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -17587,6 +17599,18 @@
 <!--96ED899EC5704BA9961340A934B62133-->  <OBJECT_TYPE><![CDATA[S]]></OBJECT_TYPE>
 <!--96ED899EC5704BA9961340A934B62133--></AD_MODEL_OBJECT>
 
+<!--977B19742A98458BB43405C215B10F1A--><AD_MODEL_OBJECT>
+<!--977B19742A98458BB43405C215B10F1A-->  <AD_MODEL_OBJECT_ID><![CDATA[977B19742A98458BB43405C215B10F1A]]></AD_MODEL_OBJECT_ID>
+<!--977B19742A98458BB43405C215B10F1A-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--977B19742A98458BB43405C215B10F1A-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--977B19742A98458BB43405C215B10F1A-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--977B19742A98458BB43405C215B10F1A-->  <ACTION><![CDATA[X]]></ACTION>
+<!--977B19742A98458BB43405C215B10F1A-->  <CLASSNAME><![CDATA[org.openbravo.erpCommon.utility.Register]]></CLASSNAME>
+<!--977B19742A98458BB43405C215B10F1A-->  <ISDEFAULT><![CDATA[Y]]></ISDEFAULT>
+<!--977B19742A98458BB43405C215B10F1A-->  <AD_FORM_ID><![CDATA[3D8AB0C824ED4C70ADE086D9CFE5DA1A]]></AD_FORM_ID>
+<!--977B19742A98458BB43405C215B10F1A-->  <OBJECT_TYPE><![CDATA[S]]></OBJECT_TYPE>
+<!--977B19742A98458BB43405C215B10F1A--></AD_MODEL_OBJECT>
+
 <!--9931DE504494438491E5B89E7F1CF9B7--><AD_MODEL_OBJECT>
 <!--9931DE504494438491E5B89E7F1CF9B7-->  <AD_MODEL_OBJECT_ID><![CDATA[9931DE504494438491E5B89E7F1CF9B7]]></AD_MODEL_OBJECT_ID>
 <!--9931DE504494438491E5B89E7F1CF9B7-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_MODEL_OBJECT_MAPPING.xml	Fri Jan 15 12:13:55 2010 +0100
+++ b/src-db/database/sourcedata/AD_MODEL_OBJECT_MAPPING.xml	Tue Jan 19 01:39:32 2010 +0100
@@ -1927,7 +1927,7 @@
 <!--801119-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--801119-->  <AD_MODEL_OBJECT_ID><![CDATA[800856]]></AD_MODEL_OBJECT_ID>
 <!--801119-->  <MAPPINGNAME><![CDATA[/ad_reports/GeneralAccountingReports.pdf]]></MAPPINGNAME>
-<!--801119-->  <ISDEFAULT><![CDATA[Y]]></ISDEFAULT>
+<!--801119-->  <ISDEFAULT><![CDATA[N]]></ISDEFAULT>
 <!--801119--></AD_MODEL_OBJECT_MAPPING>
 
 <!--801120--><AD_MODEL_OBJECT_MAPPING>
@@ -2737,7 +2737,7 @@
 <!--801543-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--801543-->  <AD_MODEL_OBJECT_ID><![CDATA[801111]]></AD_MODEL_OBJECT_ID>
 <!--801543-->  <MAPPINGNAME><![CDATA[/ad_reports/ReportRefundSales.pdf]]></MAPPINGNAME>
-<!--801543-->  <ISDEFAULT><![CDATA[Y]]></ISDEFAULT>
+<!--801543-->  <ISDEFAULT><![CDATA[N]]></ISDEFAULT>
 <!--801543--></AD_MODEL_OBJECT_MAPPING>
 
 <!--801544--><AD_MODEL_OBJECT_MAPPING>
@@ -26630,6 +26630,26 @@
 <!--73A0528DBCE2F38BE040007F01011E2B-->  <ISDEFAULT><![CDATA[N]]></ISDEFAULT>
 <!--73A0528DBCE2F38BE040007F01011E2B--></AD_MODEL_OBJECT_MAPPING>
 
+<!--7836070C25074DC0BE71BDB571F76B55--><AD_MODEL_OBJECT_MAPPING>
+<!--7836070C25074DC0BE71BDB571F76B55-->  <AD_MODEL_OBJECT_MAPPING_ID><![CDATA[7836070C25074DC0BE71BDB571F76B55]]></AD_MODEL_OBJECT_MAPPING_ID>
+<!--7836070C25074DC0BE71BDB571F76B55-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--7836070C25074DC0BE71BDB571F76B55-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--7836070C25074DC0BE71BDB571F76B55-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--7836070C25074DC0BE71BDB571F76B55-->  <AD_MODEL_OBJECT_ID><![CDATA[800856]]></AD_MODEL_OBJECT_ID>
+<!--7836070C25074DC0BE71BDB571F76B55-->  <MAPPINGNAME><![CDATA[/ad_reports/GeneralAccountingReports.html]]></MAPPINGNAME>
+<!--7836070C25074DC0BE71BDB571F76B55-->  <ISDEFAULT><![CDATA[Y]]></ISDEFAULT>
+<!--7836070C25074DC0BE71BDB571F76B55--></AD_MODEL_OBJECT_MAPPING>
+
+<!--7AEA3C790894370FE040007F01013A5F--><AD_MODEL_OBJECT_MAPPING>
+<!--7AEA3C790894370FE040007F01013A5F-->  <AD_MODEL_OBJECT_MAPPING_ID><![CDATA[7AEA3C790894370FE040007F01013A5F]]></AD_MODEL_OBJECT_MAPPING_ID>
+<!--7AEA3C790894370FE040007F01013A5F-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--7AEA3C790894370FE040007F01013A5F-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--7AEA3C790894370FE040007F01013A5F-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--7AEA3C790894370FE040007F01013A5F-->  <AD_MODEL_OBJECT_ID><![CDATA[7AEA3C790893370FE040007F01013A5F]]></AD_MODEL_OBJECT_ID>
+<!--7AEA3C790894370FE040007F01013A5F-->  <MAPPINGNAME><![CDATA[/ad_callouts/SL_ModuleCallout.html]]></MAPPINGNAME>
+<!--7AEA3C790894370FE040007F01013A5F-->  <ISDEFAULT><![CDATA[Y]]></ISDEFAULT>
+<!--7AEA3C790894370FE040007F01013A5F--></AD_MODEL_OBJECT_MAPPING>
+
 <!--81311EAEE5834B99B7DDD85CCA4EB6C9--><AD_MODEL_OBJECT_MAPPING>
 <!--81311EAEE5834B99B7DDD85CCA4EB6C9-->  <AD_MODEL_OBJECT_MAPPING_ID><![CDATA[81311EAEE5834B99B7DDD85CCA4EB6C9]]></AD_MODEL_OBJECT_MAPPING_ID>
 <!--81311EAEE5834B99B7DDD85CCA4EB6C9-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -26640,6 +26660,16 @@
 <!--81311EAEE5834B99B7DDD85CCA4EB6C9-->  <ISDEFAULT><![CDATA[N]]></ISDEFAULT>
 <!--81311EAEE5834B99B7DDD85CCA4EB6C9--></AD_MODEL_OBJECT_MAPPING>
 
+<!--8474804F12FA418881B73DE92D237EAF--><AD_MODEL_OBJECT_MAPPING>
+<!--8474804F12FA418881B73DE92D237EAF-->  <AD_MODEL_OBJECT_MAPPING_ID><![CDATA[8474804F12FA418881B73DE92D237EAF]]></AD_MODEL_OBJECT_MAPPING_ID>
+<!--8474804F12FA418881B73DE92D237EAF-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--8474804F12FA418881B73DE92D237EAF-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--8474804F12FA418881B73DE92D237EAF-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--8474804F12FA418881B73DE92D237EAF-->  <AD_MODEL_OBJECT_ID><![CDATA[801111]]></AD_MODEL_OBJECT_ID>
+<!--8474804F12FA418881B73DE92D237EAF-->  <MAPPINGNAME><![CDATA[/ad_reports/ReportRefundSales.html]]></MAPPINGNAME>
+<!--8474804F12FA418881B73DE92D237EAF-->  <ISDEFAULT><![CDATA[Y]]></ISDEFAULT>
+<!--8474804F12FA418881B73DE92D237EAF--></AD_MODEL_OBJECT_MAPPING>
+
 <!--862CF98924604AB69ABA58D883A508F5--><AD_MODEL_OBJECT_MAPPING>
 <!--862CF98924604AB69ABA58D883A508F5-->  <AD_MODEL_OBJECT_MAPPING_ID><![CDATA[862CF98924604AB69ABA58D883A508F5]]></AD_MODEL_OBJECT_MAPPING_ID>
 <!--862CF98924604AB69ABA58D883A508F5-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -26850,6 +26880,16 @@
 <!--ECCB0A9F3EFD43BCA656BB35CE87D649-->  <ISDEFAULT><![CDATA[N]]></ISDEFAULT>
 <!--ECCB0A9F3EFD43BCA656BB35CE87D649--></AD_MODEL_OBJECT_MAPPING>
 
+<!--EDC256EABE1F4A5BBBF79673328341E0--><AD_MODEL_OBJECT_MAPPING>
+<!--EDC256EABE1F4A5BBBF79673328341E0-->  <AD_MODEL_OBJECT_MAPPING_ID><![CDATA[EDC256EABE1F4A5BBBF79673328341E0]]></AD_MODEL_OBJECT_MAPPING_ID>
+<!--EDC256EABE1F4A5BBBF79673328341E0-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--EDC256EABE1F4A5BBBF79673328341E0-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--EDC256EABE1F4A5BBBF79673328341E0-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--EDC256EABE1F4A5BBBF79673328341E0-->  <AD_MODEL_OBJECT_ID><![CDATA[977B19742A98458BB43405C215B10F1A]]></AD_MODEL_OBJECT_ID>
+<!--EDC256EABE1F4A5BBBF79673328341E0-->  <MAPPINGNAME><![CDATA[/ad_forms/Register.html]]></MAPPINGNAME>
+<!--EDC256EABE1F4A5BBBF79673328341E0-->  <ISDEFAULT><![CDATA[Y]]></ISDEFAULT>
+<!--EDC256EABE1F4A5BBBF79673328341E0--></AD_MODEL_OBJECT_MAPPING>
+
 <!--F171914D8B8A47D3A8492ABB85CE87D6--><AD_MODEL_OBJECT_MAPPING>
 <!--F171914D8B8A47D3A8492ABB85CE87D6-->  <AD_MODEL_OBJECT_MAPPING_ID><![CDATA[F171914D8B8A47D3A8492ABB85CE87D6]]></AD_MODEL_OBJECT_MAPPING_ID>
 <!--F171914D8B8A47D3A8492ABB85CE87D6-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_PROCESS.xml	Fri Jan 15 12:13:55 2010 +0100
+++ b/src-db/database/sourcedata/AD_PROCESS.xml	Tue Jan 19 01:39:32 2010 +0100
@@ -3275,7 +3275,7 @@
 <!--800080-->  <AD_PROCESS_ID><![CDATA[800080]]></AD_PROCESS_ID>
 <!--800080-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
 <!--800080-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--800080-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--800080-->  <ISACTIVE><![CDATA[N]]></ISACTIVE>
 <!--800080-->  <VALUE><![CDATA[GenerateModel347]]></VALUE>
 <!--800080-->  <NAME><![CDATA[Generate 347 Model]]></NAME>
 <!--800080-->  <DESCRIPTION><![CDATA[Generate model 347]]></DESCRIPTION>
@@ -3286,6 +3286,7 @@
 <!--800080-->  <ISDIRECTPRINT><![CDATA[N]]></ISDIRECTPRINT>
 <!--800080-->  <ISBACKGROUND><![CDATA[N]]></ISBACKGROUND>
 <!--800080-->  <ISJASPER><![CDATA[N]]></ISJASPER>
+<!--800080-->  <ISEXTERNALSERVICE><![CDATA[N]]></ISEXTERNALSERVICE>
 <!--800080-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--800080-->  <UIPATTERN><![CDATA[M]]></UIPATTERN>
 <!--800080--></AD_PROCESS>
--- a/src-db/database/sourcedata/AD_TABLE.xml	Fri Jan 15 12:13:55 2010 +0100
+++ b/src-db/database/sourcedata/AD_TABLE.xml	Tue Jan 19 01:39:32 2010 +0100
@@ -347,7 +347,7 @@
 <!--116-->  <TABLENAME><![CDATA[AD_Menu]]></TABLENAME>
 <!--116-->  <CLASSNAME><![CDATA[Menu]]></CLASSNAME>
 <!--116-->  <ISVIEW><![CDATA[N]]></ISVIEW>
-<!--116-->  <ACCESSLEVEL><![CDATA[6]]></ACCESSLEVEL>
+<!--116-->  <ACCESSLEVEL><![CDATA[4]]></ACCESSLEVEL>
 <!--116-->  <AD_WINDOW_ID><![CDATA[105]]></AD_WINDOW_ID>
 <!--116-->  <ISSECURITYENABLED><![CDATA[N]]></ISSECURITYENABLED>
 <!--116-->  <ISDELETEABLE><![CDATA[Y]]></ISDELETEABLE>
--- a/src-db/database/sourcedata/AD_TREENODE.xml	Fri Jan 15 12:13:55 2010 +0100
+++ b/src-db/database/sourcedata/AD_TREENODE.xml	Tue Jan 19 01:39:32 2010 +0100
@@ -2887,7 +2887,7 @@
 <!--52118BF1A2EF4D84E040007F01005FEC-->  <NODE_ID><![CDATA[800090]]></NODE_ID>
 <!--52118BF1A2EF4D84E040007F01005FEC-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
 <!--52118BF1A2EF4D84E040007F01005FEC-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--52118BF1A2EF4D84E040007F01005FEC-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--52118BF1A2EF4D84E040007F01005FEC-->  <ISACTIVE><![CDATA[N]]></ISACTIVE>
 <!--52118BF1A2EF4D84E040007F01005FEC-->  <PARENT_ID><![CDATA[280]]></PARENT_ID>
 <!--52118BF1A2EF4D84E040007F01005FEC-->  <SEQNO><![CDATA[170]]></SEQNO>
 <!--52118BF1A2EF4D84E040007F01005FEC--></AD_TREENODE>
--- a/src-wad/src/org/openbravo/wad/controls/WADImageBLOB.html	Fri Jan 15 12:13:55 2010 +0100
+++ b/src-wad/src/org/openbravo/wad/controls/WADImageBLOB.html	Tue Jan 19 01:39:32 2010 +0100
@@ -21,7 +21,7 @@
 <FIELD_TMP>
 <div id="xx_inp">
   <input type="hidden" name="inpxx" id="xx" value="" onchange="logChanges(this);xx();return true;"/>
-  <table id="buttonxx" onclick="openServletNewWindow(null, null, '../utility/ImageInfoBLOB?columnName=xx', 'BUTTON', null, true, 600, 900);return false;" onmouseout="window.status='';return true;" onmouseover="window.status='xx';return true;" style="cursor: pointer;">
+  <table id="buttonxx" onclick="openServletNewWindow(null, null, '../utility/ImageInfoBLOB?columnName=xx', 'BUTTON', null, true, 600, 900);logChanges(document.getElementById('aa'));return false;" onmouseout="window.status='';return true;" onmouseover="window.status='xx';return true;" style="cursor: pointer;">
     <tr>
       <td><img src="../utility/ShowImage?id=xx" border=0 alt="xx" id="xx_R" title="xx" name="inpxx_R" class="xx"/></td>
     </tr>
--- a/src-wad/src/org/openbravo/wad/controls/WADImageBLOB.xml	Fri Jan 15 12:13:55 2010 +0100
+++ b/src-wad/src/org/openbravo/wad/controls/WADImageBLOB.xml	Tue Jan 19 01:39:32 2010 +0100
@@ -25,6 +25,7 @@
   <PARAMETER id="xx" name="callout" attribute="onchange" replace="xx();"/>
   <PARAMETER id="buttonxx" name="columnName" attribute="id" replace="xx"/>
   <PARAMETER id="buttonxx" name="columnName" attribute="onclick" replace="xx"/>
+  <PARAMETER id="buttonxx" name="columnName" attribute="onclick" replace="aa"/>
   <PARAMETER id="buttonxx" name="columnNameInp" attribute="onclick" replace="yy"/>
   <PARAMETER id="buttonxx" name="columnNameInp" attribute="onclick" replace="zz"/>
   <PARAMETER id="buttonxx" name="name" attribute="onmouseover" replace="xx"/>
--- a/src/org/openbravo/base/secureApp/HttpSecureAppServlet.java	Fri Jan 15 12:13:55 2010 +0100
+++ b/src/org/openbravo/base/secureApp/HttpSecureAppServlet.java	Tue Jan 19 01:39:32 2010 +0100
@@ -13,7 +13,9 @@
 
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.OutputStream;
 import java.io.PrintWriter;
 import java.sql.Connection;
 import java.text.DecimalFormat;
@@ -1139,6 +1141,47 @@
   }
 
   /**
+   * Saves the file and request for download. This approach is required to close the loading pop-up
+   * window.
+   */
+  public void renderFO(String strFo, HttpServletRequest request, HttpServletResponse response)
+      throws ServletException {
+    File baseDir = new File(globalParameters.strFTPDirectory);
+    UUID reportId = UUID.randomUUID();
+
+    int slashPos = request.getRequestURI().lastIndexOf("/");
+    int dotPos = request.getRequestURI().lastIndexOf(".");
+
+    String fileName = request.getRequestURI().substring(slashPos + 1, dotPos) + "-" + reportId
+        + ".pdf";
+    File pdffile = new File(baseDir, fileName);
+    OutputStream out = null;
+
+    try {
+      out = new FileOutputStream(pdffile);
+    } catch (Exception e) {
+      log4j.error(e.getMessage(), e);
+      throw new ServletException(e.getMessage());
+    }
+
+    // Generating and saving file
+    super.renderFO(strFo, out);
+
+    try {
+      printPagePopUpDownload(response.getOutputStream(), fileName);
+    } catch (IOException e) {
+      try {
+        FileUtility f = new FileUtility(globalParameters.strFTPDirectory, fileName, false, true);
+        if (f.exists())
+          f.deleteFile();
+      } catch (IOException ioex) {
+        log4j.error("Error trying to delete temporary report file " + fileName + " : "
+            + ioex.getMessage());
+      }
+    }
+  }
+
+  /**
    * Saves the report on the attachments folder for future retrieval
    * 
    * @param vars
--- a/src/org/openbravo/base/secureApp/LoginHandler.java	Fri Jan 15 12:13:55 2010 +0100
+++ b/src/org/openbravo/base/secureApp/LoginHandler.java	Tue Jan 19 01:39:32 2010 +0100
@@ -25,6 +25,7 @@
 import org.openbravo.erpCommon.obps.ActivationKey;
 import org.openbravo.erpCommon.utility.Utility;
 import org.openbravo.model.ad.module.Module;
+import org.openbravo.model.ad.system.Client;
 import org.openbravo.model.ad.system.SystemInformation;
 import org.openbravo.xmlEngine.XmlDocument;
 
@@ -61,8 +62,14 @@
         req.getSession(true).setAttribute("#Authenticated_user", strUserAuth);
         checkLicenseAndGo(res, vars, strUserAuth);
       } else {
-        goToRetry(res, vars, null, "Identification failure. Try again.", "Error",
-            "../security/Login_FS.html");
+        Client systemClient = OBDal.getInstance().get(Client.class, "0");
+
+        String failureTitle = Utility.messageBD(this, "IDENTIFICATION_FAILURE_TITLE", systemClient
+            .getLanguage().getLanguage());
+        String failureMessage = Utility.messageBD(this, "IDENTIFICATION_FAILURE_MSG", systemClient
+            .getLanguage().getLanguage());
+
+        goToRetry(res, vars, failureMessage, failureTitle, "Error", "../security/Login_FS.html");
       }
     }
   }
@@ -173,12 +180,9 @@
     xmlDocument.setParameter("messageType", msgType);
     xmlDocument.setParameter("action", action);
     xmlDocument.setParameter("messageTitle", title);
-    xmlDocument
-        .setParameter(
-            "messageMessage",
-            (message != null && !message.equals("")) ? message
-                : "Please enter your username and password. "
-                    + "<br>You must also ensure that your browser accepts cookies.<br>Press back to return.");
+    String msg = (message != null && !message.equals("")) ? message
+        : "Please enter your username and password.";
+    xmlDocument.setParameter("messageMessage", msg.replaceAll("\\\\n", "<br>"));
 
     response.setContentType("text/html");
     final PrintWriter out = response.getWriter();
--- a/src/org/openbravo/base/secureApp/PopUp_Download.html	Fri Jan 15 12:13:55 2010 +0100
+++ b/src/org/openbravo/base/secureApp/PopUp_Download.html	Tue Jan 19 01:39:32 2010 +0100
@@ -16,10 +16,12 @@
 <link rel="shortcut icon" href="../../../../../web/images/favicon.ico" type="image/x-icon" />
 <script language="javascript">
     function onLoadDo(url) {
-      if(typeof top.opener.top.appFrame != 'undefined') 
+      if(typeof top.opener.top.appFrame !== 'undefined') {
         top.opener.top.appFrame.document.location.href = url;
-      else
+      }
+      else {
           top.opener.top.document.location.href = url;
+      }
       top.window.close();
     }
   </script>
--- a/src/org/openbravo/erpCommon/ad_actionButton/InsertAcces.java	Fri Jan 15 12:13:55 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_actionButton/InsertAcces.java	Tue Jan 19 01:39:32 2010 +0100
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SL 
- * All portions are Copyright (C) 2001-2009 Openbravo SL 
+ * All portions are Copyright (C) 2001-2010 Openbravo SL 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -161,16 +161,24 @@
             log4j.error("Action: " + accesData[i].action + " window: " + accesData[i].adwindowid);
             InsertAccesData.insertWindow(this, accesData[i].adwindowid, roleid, vars.getClient(),
                 "0", vars.getUser());
-            if (!accesData[i].printreport.equals(""))
+            if (!accesData[i].printreport.equals("")
+                && (InsertAccesData.selectProcess(this, roleid, accesData[i].printreport) == null || InsertAccesData
+                    .selectProcess(this, roleid, accesData[i].printreport).equals(""))) {
+              log4j.error("Action window print report: " + accesData[i].printreport);
               InsertAccesData.insertProcess(this, accesData[i].printreport, roleid, vars
                   .getClient(), "0", vars.getUser());
+            }
             InsertAccesData[] buttons = InsertAccesData.selectWindowButtons(this,
                 accesData[i].adwindowid, roleid);
             if (buttons != null && buttons.length > 0) {
               for (int j = 0; j < buttons.length; j++) {
-                log4j.error("Action window button: " + buttons[j].adprocessid);
-                InsertAccesData.insertProcess(this, buttons[j].adprocessid, roleid, vars
-                    .getClient(), "0", vars.getUser());
+                if (InsertAccesData.selectProcess(this, roleid, buttons[j].adprocessid) == null
+                    || InsertAccesData.selectProcess(this, roleid, buttons[j].adprocessid).equals(
+                        "")) {
+                  log4j.error("Action window button: " + buttons[j].adprocessid);
+                  InsertAccesData.insertProcess(this, buttons[j].adprocessid, roleid, vars
+                      .getClient(), "0", vars.getUser());
+                }
               }
             }
           } else if (accesData[i].action.equals("P")
--- a/src/org/openbravo/erpCommon/ad_callouts/SE_Expense_BP_Project.java	Fri Jan 15 12:13:55 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_callouts/SE_Expense_BP_Project.java	Tue Jan 19 01:39:32 2010 +0100
@@ -79,9 +79,9 @@
         if (strBPartner != null && !strBPartner.equals("")) {
           strBPartnerId = strBPartner;
           strBPartnerName = SEExpenseBPProjectData.selectBPName(this, strProjectId);
+          resultado.append(", new Array(\"inpcBpartnerId\", \"" + strBPartnerId + "\")\n");
+          resultado.append(", new Array(\"inpcBpartnerId_R\", \"" + strBPartnerName + "\")\n");
         }
-        resultado.append(", new Array(\"inpcBpartnerId\", \"" + strBPartnerId + "\")\n");
-        resultado.append(", new Array(\"inpcBpartnerId_R\", \"" + strBPartnerName + "\")\n");
       }
     } else if (strChanged.equals("inpcBpartnerId")) {
       // If business partner changed...
@@ -97,10 +97,11 @@
           // business partner, take the last project of that business
           // partner (if any).
           if (strBPartnerProject == null || strBPartnerProject.equals("")) {
-            strReset = "1";
+            //strReset = "1";
             strProject = SEExpenseBPProjectData.selectProjectId(this, strBPartnerId);
             if (strProject != null && !strProject.equals("")) {
               strProjectId = strProject;
+              resultado.append("new Array(\"inpcProjectId\", \"" + strProjectId + "\")\n");
             } else {
               strProjectId = "";
             }
@@ -119,7 +120,6 @@
           resultado.append("new Array(\"inpcProjectphaseId\", \"\"),\n");
           resultado.append("new Array(\"inpcProjecttaskId\", \"\"),\n");
         }
-        resultado.append("new Array(\"inpcProjectId\", \"" + strProjectId + "\")\n");
       }
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/erpCommon/ad_callouts/SL_ModuleCallout.java	Tue Jan 19 01:39:32 2010 +0100
@@ -0,0 +1,116 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (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 SL 
+ * All portions are Copyright (C) 2010 Openbravo SL 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.erpCommon.ad_callouts;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.hibernate.criterion.Expression;
+import org.openbravo.base.secureApp.HttpSecureAppServlet;
+import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.dal.service.OBCriteria;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.erpCommon.utility.Utility;
+import org.openbravo.model.ad.module.Module;
+import org.openbravo.xmlEngine.XmlDocument;
+
+public class SL_ModuleCallout extends HttpSecureAppServlet {
+
+  private static final long serialVersionUID = 1L;
+
+  public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,
+      ServletException {
+    VariablesSecureApp vars = new VariablesSecureApp(request);
+    if (vars.commandIn("DEFAULT")) {
+      String strChanged = vars.getStringParameter("inpLastFieldChanged");
+      if (log4j.isDebugEnabled())
+        log4j.debug("CHANGED: " + strChanged);
+      String strADModuleID = vars.getStringParameter("inpadModuleId");
+
+      try {
+        String moduleType = vars.getStringParameter("inptype");
+        String isInDev = vars.getStringParameter("inpisindevelopment");
+        if (isInDev.equals("Y") && moduleType.equals("T")) {
+          templateInDev(response, vars, strADModuleID);
+        } else {
+          printPageResult(response, "");
+        }
+      } catch (ServletException ex) {
+        pageErrorCallOut(response);
+      }
+    } else
+      pageError(response);
+  }
+
+  /**
+   * Checks if there are multiple templates in development. If so, unsets the is indevelopment
+   * property from the current record.
+   */
+  private void templateInDev(HttpServletResponse response, VariablesSecureApp vars,
+      String strADModuleID) throws IOException, ServletException {
+    // Check whether there are more templates in development
+    OBCriteria<Module> obc = OBDal.getInstance().createCriteria(Module.class);
+    obc.add(Expression.eq(Module.PROPERTY_TYPE, "T"));
+    obc.add(Expression.eq(Module.PROPERTY_INDEVELOPMENT, true));
+    if (strADModuleID != null && !strADModuleID.equals("")) {
+      obc.add(Expression.ne(Module.PROPERTY_ID, strADModuleID));
+    }
+    String devTemplates = "";
+    for (Module template : obc.list()) {
+      devTemplates += template.getName() + " ";
+    }
+
+    StringBuffer result = new StringBuffer();
+
+    if (!devTemplates.equals("")) {
+      // There are other template(s) in dev
+      result.append("new Array(\"MESSAGE\", \"" + devTemplates + " "
+          + Utility.messageBD(this, "MultipleDevelopmentTemplates", vars.getLanguage()) + "\"),\n");
+      result.append("new Array(\"inpisindevelopment\", \"N\")");
+    }
+
+    printPageResult(response, result.toString());
+  }
+
+  /**
+   * Composes the standard callout response
+   */
+  private void printPageResult(HttpServletResponse response, String result) throws IOException {
+    StringBuffer resultado = new StringBuffer();
+    resultado.append("var calloutName='SL_ModuleCallout';\n\n");
+    resultado.append("var respuesta = new Array(");
+    resultado.append(result);
+    resultado.append(");");
+
+    XmlDocument xmlDocument = xmlEngine.readXmlTemplate(
+        "org/openbravo/erpCommon/ad_callouts/CallOut").createXmlDocument();
+    xmlDocument.setParameter("array", resultado.toString());
+    xmlDocument.setParameter("frameName", "appFrame");
+    response.setContentType("text/html; charset=UTF-8");
+    PrintWriter out = response.getWriter();
+    out.println(xmlDocument.print());
+    out.close();
+  }
+
+}
--- a/src/org/openbravo/erpCommon/ad_forms/RequisitionToOrder.java	Fri Jan 15 12:13:55 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/RequisitionToOrder.java	Tue Jan 19 01:39:32 2010 +0100
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SL 
- * All portions are Copyright (C) 2008-2009 Openbravo SL 
+ * All portions are Copyright (C) 2008-2010 Openbravo SL 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -485,11 +485,11 @@
       BigDecimal qtyOrder = new BigDecimal("0");
       boolean insertLine = false;
 
-      RequisitionToOrderData[] lines = RequisitionToOrderData.linesToOrder(this, strOrderDate,
-          RequisitionToOrderData.cBPartnerLocationId(this, strVendor), strPriceListVersionId,
-          cCurrencyId, strOrg, strWarehouse, RequisitionToOrderData.billto(this, strVendor).equals(
-              "") ? RequisitionToOrderData.cBPartnerLocationId(this, strVendor)
-              : RequisitionToOrderData.billto(this, strVendor), strSelected);
+      RequisitionToOrderData[] lines = RequisitionToOrderData.linesToOrder(this, cCurrencyId,
+          strOrderDate, strOrg, strWarehouse, RequisitionToOrderData.billto(this, strVendor)
+              .equals("") ? RequisitionToOrderData.cBPartnerLocationId(this, strVendor)
+              : RequisitionToOrderData.billto(this, strVendor), RequisitionToOrderData
+              .cBPartnerLocationId(this, strVendor), strPriceListVersionId, strSelected);
       for (int i = 0; lines != null && i < lines.length; i++) {
         if (i == 0)
           strCOrderlineID = SequenceIdData.getUUID();
@@ -524,7 +524,7 @@
                 strOrderDate, lines[i].description, lines[i].mProductId,
                 lines[i].mAttributesetinstanceId, strWarehouse, lines[i].cUomId, qtyOrder
                     .toPlainString(), cCurrencyId, lines[i].pricelist, lines[i].priceactual,
-                lines[i].pricelimit, lines[i].tax, "", lines[i].discount);
+                strPriceListId, lines[i].pricelimit, lines[i].tax, "", lines[i].discount);
           } catch (ServletException ex) {
             myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
             releaseRollbackConnection(conn);
--- a/src/org/openbravo/erpCommon/ad_forms/RequisitionToOrder_data.xsql	Fri Jan 15 12:13:55 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/RequisitionToOrder_data.xsql	Tue Jan 19 01:39:32 2010 +0100
@@ -12,7 +12,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SL 
- * All portions are Copyright (C) 2008-2009 Openbravo SL 
+ * All portions are Copyright (C) 2008-2010 Openbravo SL 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -119,34 +119,27 @@
     <SqlMethodComment></SqlMethodComment>
     <Sql>
       <![CDATA[
-        SELECT M_REQUISITIONLINE.M_PRODUCT_ID, M_ATTRIBUTESETINSTANCE_ID, LOCKQTY, M_REQUISITIONLINE.DESCRIPTION, C_UOM_ID, 
+        SELECT M_REQUISITIONLINE.M_PRODUCT_ID, M_ATTRIBUTESETINSTANCE_ID, LOCKQTY, DESCRIPTION, C_UOM_ID, 
           M_REQUISITIONLINE_ID, '' AS C_ORDERLINE_ID,
           COALESCE(M_PRODUCTPRICE.PRICELIST, M_REQUISITIONLINE.PRICELIST, LOCKPRICE) AS PRICELIST,
           COALESCE(M_PRODUCTPRICE.PRICELIMIT, LOCKPRICE) AS PRICELIMIT,
           COALESCE(M_PRODUCTPRICE.PRICESTD, LOCKPRICE) AS PRICESTD,
-          ROUND(COALESCE(LOCKPRICE, M_GET_OFFERS_PRICE(TO_DATE(?), (SELECT C_BPARTNER_ID FROM C_BPARTNER_LOCATION WHERE C_BPARTNER_LOCATION_ID = ?), M_REQUISITIONLINE.M_PRODUCT_ID, M_PRODUCTPRICE.PRICESTD, LOCKQTY, (SELECT M_PRICELIST_ID FROM M_PRICELIST_VERSION WHERE M_PRICELIST_VERSION_ID = ?))),(SELECT PRICEPRECISION FROM C_CURRENCY WHERE C_CURRENCY_ID = ?)) AS PRICEACTUAL,
+          ROUND(COALESCE(LOCKPRICE, M_PRODUCTPRICE.PRICESTD),(SELECT PRICEPRECISION FROM C_CURRENCY WHERE C_CURRENCY_ID = ?)) AS PRICEACTUAL,
           CASE WHEN COALESCE(M_PRODUCTPRICE.PRICELIST, M_REQUISITIONLINE.PRICELIST, LOCKPRICE) = 0 THEN 0 ELSE
-          ROUND((COALESCE(M_PRODUCTPRICE.PRICELIST, M_REQUISITIONLINE.PRICELIST, LOCKPRICE) - COALESCE(LOCKPRICE, M_GET_OFFERS_PRICE(TO_DATE(?), (SELECT C_BPARTNER_ID FROM C_BPARTNER_LOCATION WHERE C_BPARTNER_LOCATION_ID = ?), M_REQUISITIONLINE.M_PRODUCT_ID, M_PRODUCTPRICE.PRICESTD, LOCKQTY, (SELECT M_PRICELIST_ID FROM M_PRICELIST_VERSION WHERE M_PRICELIST_VERSION_ID = ?))))/
+          ROUND((COALESCE(M_PRODUCTPRICE.PRICELIST, M_REQUISITIONLINE.PRICELIST, LOCKPRICE) - COALESCE(LOCKPRICE, M_PRODUCTPRICE.PRICESTD))/
                    COALESCE(M_PRODUCTPRICE.PRICELIST, M_REQUISITIONLINE.PRICELIST, LOCKPRICE)*100,
                 (SELECT STDPRECISION FROM C_CURRENCY WHERE C_CURRENCY_ID = ?)) END AS DISCOUNT,
           C_GetTax(M_REQUISITIONLINE.M_PRODUCT_ID, to_date(?), ?, ?, ?, ?, null, 'N') AS TAX,
           CASE WHEN LOCKQTY < (M_REQUISITIONLINE.QTY - M_REQUISITIONLINE.ORDEREDQTY) THEN 'N' ELSE 'Y' END AS TO_CLOSE
-        FROM M_REQUISITION, M_REQUISITIONLINE LEFT JOIN M_PRODUCTPRICE
+        FROM M_REQUISITIONLINE LEFT JOIN M_PRODUCTPRICE
                                          ON M_REQUISITIONLINE.M_PRODUCT_ID = M_PRODUCTPRICE.M_PRODUCT_ID
                                             AND M_PRODUCTPRICE.M_PRICELIST_VERSION_ID = ?
         WHERE 1=1
-        AND M_REQUISITION.M_REQUISITION_ID = M_REQUISITIONLINE.M_REQUISITION_ID
         ORDER BY M_REQUISITIONLINE.M_PRODUCT_ID, M_ATTRIBUTESETINSTANCE_ID, SUPPLIERNOTES, 
-                 ROUND(COALESCE(LOCKPRICE, M_GET_OFFERS_PRICE(TO_DATE(?), (SELECT C_BPARTNER_ID FROM C_BPARTNER_LOCATION WHERE C_BPARTNER_LOCATION_ID = ?), M_REQUISITIONLINE.M_PRODUCT_ID, M_PRODUCTPRICE.PRICESTD, LOCKQTY, (SELECT M_PRICELIST_ID FROM M_PRICELIST_VERSION WHERE M_PRICELIST_VERSION_ID = ?))),(SELECT PRICEPRECISION FROM C_CURRENCY WHERE C_CURRENCY_ID = ?))
+                 ROUND(COALESCE(LOCKPRICE, M_PRODUCTPRICE.PRICESTD),(SELECT PRICEPRECISION FROM C_CURRENCY WHERE C_CURRENCY_ID = ?))
         ]]></Sql>
     <Field name="rownum" value="count"/>
-    <Parameter name="orderdate"/>
-    <Parameter name="shipto"/>
-    <Parameter name="pricelistversion"/>
     <Parameter name="currency"/>
-    <Parameter name="orderdate"/>
-    <Parameter name="shipto"/>
-    <Parameter name="pricelistversion"/>
     <Parameter name="currency"/>
     <Parameter name="orderdate"/>
     <Parameter name="org"/>
@@ -155,9 +148,6 @@
     <Parameter name="shipto"/>
     <Parameter name="pricelistversion"/>
     <Parameter name="parRequisitionLines" optional="true" type="argument" after="WHERE 1=1" text=" AND M_RequisitionLine_ID IN"/>
-    <Parameter name="orderdate"/>
-    <Parameter name="shipto"/>
-    <Parameter name="pricelistversion"/>
     <Parameter name="currency"/>
   </SqlMethod>
   <SqlMethod name="selectVendor" type="preparedStatement" return="Multiple">
@@ -456,7 +446,7 @@
     <Parameter name="mProductId"/>
     <Parameter name="priceactual"/>
     <Parameter name="qtyordered"/>
-    <Parameter name="pricelist"/>
+    <Parameter name="pricelistid"/>
     <Parameter name="pricelimit"/>
     <Parameter name="cTaxId"/>
     <Parameter name="sResourceassignmentId"/>
--- a/src/org/openbravo/erpCommon/ad_process/CashBankOperations_data.xsql	Fri Jan 15 12:13:55 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_process/CashBankOperations_data.xsql	Tue Jan 19 01:39:32 2010 +0100
@@ -42,15 +42,15 @@
 		SELECT P.AD_ORG_ID AS PADRE, C.C_BANKACCOUNT_ID AS ID, C.DISPLAYEDACCOUNT AS NAME
 		FROM AD_ORG O, AD_ORG P, C_BANKACCOUNT C
 		WHERE O.AD_ORG_ID = C.AD_ORG_ID
-		  AND AD_ISORGINCLUDED(C.AD_ORG_ID,P.AD_ORG_ID,O.AD_CLIENT_ID) <> -1
-		  AND (P.AD_CLIENT_ID = O.AD_CLIENT_ID OR P.AD_ORG_ID = '0')
+		  AND AD_ISORGINCLUDED(P.AD_ORG_ID,C.AD_ORG_ID,P.AD_CLIENT_ID) <> -1
+		  AND P.AD_ORG_ID IN (SELECT AD_ORG_ID FROM C_BANKACCOUNT)
 		  AND O.AD_ORG_ID IN ('1')
-		  AND O.AD_CLIENT_ID IN ('2')
+		  AND P.AD_CLIENT_ID IN ('2')
 		ORDER BY PADRE, NAME
       ]]>
       </Sql>
       <Parameter name="adOrgId" optional="true" type="replace" after="AND O.AD_ORG_ID IN (" text="'1'"/>
-      <Parameter name="adClientId" optional="true" type="replace" after="AND O.AD_CLIENT_ID IN (" text="'2'"/>
+      <Parameter name="adClientId" optional="true" type="replace" after="AND P.AD_CLIENT_ID IN (" text="'2'"/>
    </SqlMethod>
    <SqlMethod name="selectCashDouble" type="preparedStatement" return="multiple">
       <SqlMethodComment></SqlMethodComment>
@@ -59,16 +59,16 @@
 		SELECT P.AD_ORG_ID AS PADRE, C.C_CASHBOOK_ID AS ID, AD_COLUMN_IDENTIFIER(TO_CHAR('C_CASHBOOK'),TO_CHAR(C.C_CASHBOOK_ID),TO_CHAR(?)) AS NAME
 		FROM AD_ORG O, AD_ORG P, C_CASHBOOK C
 		WHERE O.AD_ORG_ID = C.AD_ORG_ID
-		  AND AD_ISORGINCLUDED(C.AD_ORG_ID,P.AD_ORG_ID,O.AD_CLIENT_ID) <> -1
-		  AND (P.AD_CLIENT_ID = O.AD_CLIENT_ID OR P.AD_ORG_ID = '0')
+		  AND AD_ISORGINCLUDED(P.AD_ORG_ID,C.AD_ORG_ID,P.AD_CLIENT_ID) <> -1
+		  AND P.AD_ORG_ID IN (SELECT AD_ORG_ID FROM C_CASHBOOK)
 		  AND O.AD_ORG_ID IN ('1')
-		  AND O.AD_CLIENT_ID IN ('2')
+		  AND P.AD_CLIENT_ID IN ('2')
 		ORDER BY PADRE, NAME
       ]]>
       </Sql>
       <Parameter name="adLanguage"/>
       <Parameter name="adOrgId" optional="true" type="replace" after="AND O.AD_ORG_ID IN (" text="'1'"/>
-      <Parameter name="adClientId" optional="true" type="replace" after="AND O.AD_CLIENT_ID IN (" text="'2'"/>
+      <Parameter name="adClientId" optional="true" type="replace" after="AND P.AD_CLIENT_ID IN (" text="'2'"/>
    </SqlMethod>
   <SqlMethod name="select" type="preparedStatement" return="String">
     <SqlMethodComment></SqlMethodComment>
--- a/src/org/openbravo/erpCommon/ad_reports/ReportInvoiceCustomerEdition.java	Fri Jan 15 12:13:55 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportInvoiceCustomerEdition.java	Tue Jan 19 01:39:32 2010 +0100
@@ -126,7 +126,7 @@
           "ReportInvoiceCustomerEdition|SalesRepId");
       String strcRegionId = vars.getRequestInGlobalVariable("inpcRegionId",
           "ReportInvoiceCustomerEdition|cRegionId", IsIDFilter.instance);
-      printPagePdf(response, vars, strdateFrom, strdateTo, strcProjectId, strcBpartnerId,
+      printPagePdf(request, response, vars, strdateFrom, strdateTo, strcProjectId, strcBpartnerId,
           strmCategoryId, strProjectkind, strProjectstatus, strProjectphase, strProduct,
           strProjectpublic, strSalesRep, strcRegionId);
     } else
@@ -327,9 +327,9 @@
     out.close();
   }
 
-  private void printPagePdf(HttpServletResponse response, VariablesSecureApp vars,
-      String strdateFrom, String strdateTo, String strcProjectId, String strcBpartnerId,
-      String strmCategoryId, String strProjectkind, String strProjectstatus,
+  private void printPagePdf(HttpServletRequest request, HttpServletResponse response,
+      VariablesSecureApp vars, String strdateFrom, String strdateTo, String strcProjectId,
+      String strcBpartnerId, String strmCategoryId, String strProjectkind, String strProjectstatus,
       String strProjectphase, String strProduct, String strProjectpublic, String strSalesRep,
       String strcRegionId) throws IOException, ServletException {
     if (log4j.isDebugEnabled())
@@ -349,7 +349,7 @@
     String strResult = xmlDocument.print();
     if (log4j.isDebugEnabled())
       log4j.debug(strResult);
-    renderFO(strResult, response);
+    renderFO(strResult, request, response);
   }
 
   public String getServletInfo() {
--- a/src/org/openbravo/erpCommon/ad_reports/ReportPricelist.html	Fri Jan 15 12:13:55 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportPricelist.html	Tue Jan 19 01:39:32 2010 +0100
@@ -53,7 +53,7 @@
 function imprimir()
 {
 	if (validate()){
-		openPDFFiltered("ReportPricelist.pdf","PDF");
+		openPDFFiltered("ReportPricelist.html","PDF");
 	}
 	return true;
 }
--- a/src/org/openbravo/erpCommon/ad_reports/ReportPricelist.java	Fri Jan 15 12:13:55 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportPricelist.java	Tue Jan 19 01:39:32 2010 +0100
@@ -77,7 +77,8 @@
           "ReportPricelist|pricelistversion");
       String strmProductId = vars.getRequestInGlobalVariable("inpmProductId_IN",
           "ReportPricelist|mProductId", IsIDFilter.instance);
-      printPagePdf(response, vars, strProductCategory, strPricelistversionId, strmProductId);
+      printPagePdf(request, response, vars, strProductCategory, strPricelistversionId,
+          strmProductId);
     } else
       pageError(response);
   }
@@ -185,9 +186,9 @@
     out.close();
   }
 
-  private void printPagePdf(HttpServletResponse response, VariablesSecureApp vars,
-      String strProductCategory, String strPricelistversionId, String strmProductId)
-      throws IOException, ServletException {
+  private void printPagePdf(HttpServletRequest request, HttpServletResponse response,
+      VariablesSecureApp vars, String strProductCategory, String strPricelistversionId,
+      String strmProductId) throws IOException, ServletException {
     if (log4j.isDebugEnabled())
       log4j.debug("Output: print pdf");
     XmlDocument xmlDocument = null;
@@ -200,7 +201,7 @@
     String strResult = xmlDocument.print();
     if (log4j.isDebugEnabled())
       log4j.debug(strResult);
-    renderFO(strResult, response);
+    renderFO(strResult, request, response);
   }
 
   public String getServletInfo() {
--- a/src/org/openbravo/erpCommon/ad_reports/ReportRefundSalesDimensionalAnalysesFilter.html	Fri Jan 15 12:13:55 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportRefundSalesDimensionalAnalysesFilter.html	Tue Jan 19 01:39:32 2010 +0100
@@ -55,7 +55,7 @@
 function imprimir()
 {
 	if (validate()){
-		openPDFFiltered("ReportRefundSales.pdf","PDF");
+		openPDFFiltered("ReportRefundSales.html","PDF");
 	}
 	return true;
 }
--- a/src/org/openbravo/erpCommon/ad_reports/ReportRefundSalesDimensionalAnalysesPDF.java	Fri Jan 15 12:13:55 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportRefundSalesDimensionalAnalysesPDF.java	Tue Jan 19 01:39:32 2010 +0100
@@ -368,7 +368,7 @@
         xmlDocument.setData("structure2", data);
       }
       String strResult = xmlDocument.print();
-      renderFO(strResult, response);
+      renderFO(strResult, request, response);
     }
   }
 
--- a/src/org/openbravo/erpCommon/ad_reports/ReportTrialBalance.html	Fri Jan 15 12:13:55 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportTrialBalance.html	Tue Jan 19 01:39:32 2010 +0100
@@ -54,7 +54,7 @@
 
 function imprimir()
 {
-	openPDFFiltered("ReportTrialBalancePDF.pdf?Command=PDF","PDF");
+	openPDFFiltered("ReportTrialBalance.html?Command=PDF","PDF");
 	return true;
 }
 </script>
--- a/src/org/openbravo/erpCommon/ad_reports/ReportTrialBalance.java	Fri Jan 15 12:13:55 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportTrialBalance.java	Tue Jan 19 01:39:32 2010 +0100
@@ -110,7 +110,7 @@
       String strcBpartnerId = vars.getRequestInGlobalVariable("inpcBPartnerId_IN",
           "ReportTrialBalance|cBpartnerId", IsIDFilter.instance);
       String strAll = vars.getStringParameter("inpAll");
-      printPageDataPDF(response, vars, strDateFrom, strDateTo, strOrg, strLevel, strOnly,
+      printPageDataPDF(request, response, vars, strDateFrom, strDateTo, strOrg, strLevel, strOnly,
           strAccountFrom, strAccountTo, strAll, strcBpartnerId, strcAcctSchemaId);
     } else
       pageError(response);
@@ -331,10 +331,10 @@
     out.close();
   }
 
-  private void printPageDataPDF(HttpServletResponse response, VariablesSecureApp vars,
-      String strDateFrom, String strDateTo, String strOrg, String strLevel, String strOnly,
-      String strAccountFrom, String strAccountTo, String strAll, String strcBpartnerId,
-      String strcAcctSchemaId) throws IOException, ServletException {
+  private void printPageDataPDF(HttpServletRequest request, HttpServletResponse response,
+      VariablesSecureApp vars, String strDateFrom, String strDateTo, String strOrg,
+      String strLevel, String strOnly, String strAccountFrom, String strAccountTo, String strAll,
+      String strcBpartnerId, String strcAcctSchemaId) throws IOException, ServletException {
     if (log4j.isDebugEnabled())
       log4j.debug("Output: dataSheet");
     /*
@@ -431,7 +431,7 @@
     }
 
     String strResult = xmlDocument.print();
-    renderFO(strResult, response);
+    renderFO(strResult, request, response);
     /*
      * out.println(xmlDocument.print()); out.close();
      */
--- a/src/org/openbravo/erpCommon/businessUtility/Buscador.java	Fri Jan 15 12:13:55 2010 +0100
+++ b/src/org/openbravo/erpCommon/businessUtility/Buscador.java	Tue Jan 19 01:39:32 2010 +0100
@@ -98,7 +98,7 @@
         if (data == null || data.length == 0) {
           if (log4j.isDebugEnabled())
             log4j.debug("The columns defined were parent keys");
-          bdError(request, response, "SearchNothing", vars.getLanguage());
+          advisePopUp(request, response, "SearchNothing", Utility.messageBD(this, "SearchNothing", vars.getLanguage()));
         } else
           printPage(response, vars, strTab, data, strWindow, strWindowId, strIsSOTrx);
       }
--- a/src/org/openbravo/erpCommon/info/ImageInfoBLOB.html	Fri Jan 15 12:13:55 2010 +0100
+++ b/src/org/openbravo/erpCommon/info/ImageInfoBLOB.html	Tue Jan 19 01:39:32 2010 +0100
@@ -90,8 +90,6 @@
 
   <script language="JavaScript" type="text/javascript">
   function onLoadDo(){
-
-    setWindowElementFocus('firstElement');
   }
 
   function onResizeDo(){
--- a/src/org/openbravo/erpCommon/info/ImageInfoBLOB.java	Fri Jan 15 12:13:55 2010 +0100
+++ b/src/org/openbravo/erpCommon/info/ImageInfoBLOB.java	Tue Jan 19 01:39:32 2010 +0100
@@ -149,7 +149,6 @@
             OBDal.getInstance().flush();
             OBDal.getInstance().remove(image);
           } catch (Exception e) {
-            e.printStackTrace();
             log4j.error("Class for table not found", e);
           }
         } finally {
@@ -214,7 +213,13 @@
           + "_R').className = \"dummyClass_\" + parent.opener.document.getElementById('"
           + columnname + "_R').className;");
     }
-    writer.println("window.close()");
+
+    // When deleting an image, reset parent status to not changed in order to avoid trigger Autosave
+    if (imageId.equals("")) {
+      writer.println("parentWindow.isUserChanges = false;");
+      writer.println("parentWindow.document.forms[0].inpLastFieldChanged.value=\"\";");
+    }
+    writer.println("window.close();");
 
     writer.println("try { parentWindow.changeToEditingMode('force'); } catch (e) {}");
     writer.println("}");
--- a/src/org/openbravo/erpCommon/utility/Home.html	Fri Jan 15 12:13:55 2010 +0100
+++ b/src/org/openbravo/erpCommon/utility/Home.html	Tue Jan 19 01:39:32 2010 +0100
@@ -99,6 +99,6 @@
       </td>
     </tr>
   </table>
-
+<script type="text/javascript" id="customJS"></script>
 </body>
 </html>
--- a/src/org/openbravo/erpCommon/utility/Home.xml	Fri Jan 15 12:13:55 2010 +0100
+++ b/src/org/openbravo/erpCommon/utility/Home.xml	Tue Jan 19 01:39:32 2010 +0100
@@ -12,7 +12,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SL 
- * All portions are Copyright (C) 2001-2007 Openbravo SL 
+ * All portions are Copyright (C) 2001-2009 Openbravo SL 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -24,4 +24,5 @@
 	<PARAMETER id="paramLanguage" name="language" default=""/>
 	<PARAMETER id="paramCSS" name="theme" attribute="href" replace="Default"/>
   <PARAMETER id="tdleftTabs" name="leftTabs" default=""/>
+  <PARAMETER id="customJS" name="customJS" default="" />
 </REPORT>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/erpCommon/utility/Register.java	Tue Jan 19 01:39:32 2010 +0100
@@ -0,0 +1,91 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (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 SL
+ * All portions are Copyright (C) 2009 Openbravo SL
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.erpCommon.utility;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.openbravo.base.secureApp.HttpSecureAppServlet;
+import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.ad.system.SystemInformation;
+import org.openbravo.xmlEngine.XmlDocument;
+
+public class Register extends HttpSecureAppServlet {
+
+  private static final long serialVersionUID = 1L;
+  private static final String URL = "http://www.openbravo.com/embedreg/form/";
+
+  @Override
+  public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,
+      ServletException {
+    final VariablesSecureApp vars = new VariablesSecureApp(request);
+    if (vars.commandIn("DEFAULT")) {
+      printPage(response, vars);
+    } else
+      pageError(response);
+  }
+
+  private void printPage(HttpServletResponse response, VariablesSecureApp vars) throws IOException,
+      ServletException {
+
+    XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/utility/Home")
+        .createXmlDocument();
+    xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";\n");
+    xmlDocument.setParameter("language", "defaultLang=\"" + vars.getLanguage() + "\";");
+    xmlDocument.setParameter("theme", vars.getTheme());
+
+    // Getting system id
+    SystemInformation sysInfo = OBDal.getInstance().get(SystemInformation.class, "0");
+
+    if (sysInfo != null) {
+      // Generating JavaScript code to open registration form
+      String sysId = sysInfo.getSystemIdentifier() != null
+          || sysInfo.getSystemIdentifier().equals("") ? sysInfo.getSystemIdentifier() : "";
+
+      String formURL = URL;
+
+      if (!sysId.equals("")) {
+        // Append system identifier
+        formURL += "?system_id=" + sysId;
+      }
+
+      String jsCode = "(function(){window.open('" + formURL + "');})();";
+
+      // Setting jsCode
+      xmlDocument.setParameter("customJS", jsCode);
+    }
+    LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "Home.html", strReplaceWith);
+    xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
+    response.setContentType("text/html; charset=UTF-8");
+    PrintWriter out = response.getWriter();
+    out.println(xmlDocument.print());
+    out.close();
+  }
+
+  @Override
+  public String getServletInfo() {
+    return "Register servlet. Opens a new window with Openbravo's website registration form";
+  }
+}
--- a/src/org/openbravo/erpCommon/utility/ToolBar.java	Fri Jan 15 12:13:55 2010 +0100
+++ b/src/org/openbravo/erpCommon/utility/ToolBar.java	Tue Jan 19 01:39:32 2010 +0100
@@ -513,6 +513,9 @@
       removeAllTests();
     if (isReadOnly)
       removeReadOnly();
+    if (!email) {
+      removeElement("EMAIL");
+    }
   }
 
   // AL New toolbars
--- a/src/org/openbravo/erpCommon/utility/VerticalMenu.html	Fri Jan 15 12:13:55 2010 +0100
+++ b/src/org/openbravo/erpCommon/utility/VerticalMenu.html	Tue Jan 19 01:39:32 2010 +0100
@@ -40,7 +40,7 @@
       //all dojo.require above this line
       dojo.hostenv.writeIncludes(); //makes debugging in Venkman possible
     </script>
-    <script language="JavaScript" type="text/javascript">
+    <script type="text/javascript">
       function resizeMenu() {
         var mnu = document.getElementById("Menu_Client");
         var mleft = document.getElementById("MenuLeft");
@@ -101,8 +101,7 @@
           updateData();
           setTimeout("updateAlert()", 50000);
       }
-    </script>
-    <script language="JavaScript" type="text/javascript">
+
       function onLoadDo() {
         if (frames.name.indexOf('appFrame')!=-1) {
           location.href="../utility/Home.html";
@@ -139,26 +138,59 @@
 
       function validate(action, form, value) {
          var appFrame = top.frames.appFrame;
-         if(!appFrame.isUserChanges) {
-             return true;
+
+         try {
+           var isUserChanges = appFrame.isUserChanges;
+         } catch(e1) {
+           if(isDebugEnabled()) {
+             console.error("%o", e1);
+           }
          }
-         var loc = appFrame.location.toString();
-         if( loc.indexOf('Home.html') != -1 || typeof appFrame.depurar_validate_wrapper == 'undefined') {
-             return true;
+
+         if(typeof isUserChanges === 'undefined' || !appFrame.isUserChanges) {
+           return true;
          }
+
+         try {
+           var loc = appFrame.location.toString();
+         } catch(e2) {
+           if(isDebugEnabled()) {
+             console.error("%o", e2);
+           }
+         }
+
+         if(typeof loc === 'undefined' || loc.indexOf('Home.html') !== -1 || typeof appFrame.depurar_validate_wrapper === 'undefined') {
+           return true;
+         }
+
          return appFrame.depurar_validate_wrapper(action, form, value);
       }
 
       function getForm() {
-         var appForm = top.frames.appFrame.document.forms[0];
-         var loc = top.frames.appFrame.location.toString();
-         if(loc.indexOf('Home.html') != -1 || typeof(appForm) == 'undefined') {
-       	   return null;
+         try {
+            var appForm = top.frames.appFrame.document.forms[0];
+         } catch(e1) {
+           if(isDebugEnabled()) {
+             console.error("%o", e1);
+           }
          }
-         
-         if(typeof(appForm.inpLastFieldChanged) == 'undefined' || appForm.inpLastFieldChanged.value == "") {
+
+         try {
+           var loc = top.frames.appFrame.location.toString();
+         } catch(e2) {
+           if(isDebugEnabled()) {
+             console.error("%o", e2);
+           }
+         }
+
+         if(typeof loc === 'undefined' || typeof appForm === 'undefined' || loc.indexOf('Home.html') !== -1) {
            return null;
          }
+
+         if(typeof appForm.inpLastFieldChanged === 'undefined' || appForm.inpLastFieldChanged.value === "") {
+           return null;
+         }
+
          return appForm;
       }
     </script>
--- a/src/org/openbravo/erpReports/RptM_Inout.java	Fri Jan 15 12:13:55 2010 +0100
+++ b/src/org/openbravo/erpReports/RptM_Inout.java	Tue Jan 19 01:39:32 2010 +0100
@@ -59,10 +59,9 @@
 
     RptMInoutData[] data = RptMInoutData.select(this, strmInoutId);
     String strCopies = minimumOne(RptMInoutData.selectCopies(this, strmInoutId));
-    RptMInoutData[] dataPrincipal = RptMInoutData.selectNumCopies(this, strCopies);
-    RptMInoutHeaderData[][] dataHeader = new RptMInoutHeaderData[Integer.valueOf(strCopies)
-        .intValue()][];
-    RptMInoutLinesData[][] dataLines = new RptMInoutLinesData[Integer.valueOf(strCopies).intValue()][];
+    RptMInoutData[] dataPrincipal = RptMInoutData.selectNumCopies(this, Integer.toString(data.length));
+    RptMInoutHeaderData[][] dataHeader = new RptMInoutHeaderData[data.length][];
+    RptMInoutLinesData[][] dataLines = new RptMInoutLinesData[data.length][];
     int contador = 0;
     for (int i = 0; i < data.length; i++) {
       String strDocumentCopies = minimumOne(RptMInoutData.selectDocumentcopies(this,
--- a/web/js/appStatus.js	Fri Jan 15 12:13:55 2010 +0100
+++ b/web/js/appStatus.js	Tue Jan 19 01:39:32 2010 +0100
@@ -146,6 +146,54 @@
   return true;
 }
 
+function disableFieldButton(id) {
+  var link = null;
+  try {
+    if (typeof id == "string") {
+      link = document.getElementById(id);
+    } else {
+      link = id;
+    }
+    if (link.tagName == 'A') {
+      if (link.className.indexOf('FieldButtonLink') != -1 && link.className.indexOf('FieldButtonLink_disabled') == -1) {
+        link.style.display = "none";
+        link.className = link.className.replace('FieldButtonLink', 'FieldButtonLink_disabled');
+        disableAttributeWithFunction(link, 'obj', 'onclick');
+        disableAttributeWithFunction(link, 'obj', 'onfocus');
+        disableAttributeWithFunction(link, 'obj', 'onkeypress');
+        disableAttributeWithFunction(link, 'obj', 'onkeyup');
+      }
+    }
+  } catch (e) {
+    return false;
+  }
+  return true;
+}
+
+function enableFieldButton(id) {
+  var link = null;
+  try {
+    if (typeof id == "string") {
+      link = document.getElementById(id);
+    } else {
+      link = id;
+    }
+    if (link.tagName == 'A') {
+      if (link.className.indexOf('FieldButtonLink_disabled') != -1) {
+        link.style.display = "block";
+        link.className = link.className.replace('FieldButtonLink_disabled', 'FieldButtonLink');
+        enableAttributeWithFunction(link, 'obj', 'onclick');
+        enableAttributeWithFunction(link, 'obj', 'onfocus');
+        enableAttributeWithFunction(link, 'obj', 'onkeypress');
+        enableAttributeWithFunction(link, 'obj', 'onkeyup');
+      }
+    }
+  } catch (e) {
+    return false;
+  }
+  return true;
+}
+
 function setWindowEditing(value) {
   isContextMenuOpened = false;
   var isNewWindow;
--- a/web/js/utils.js	Fri Jan 15 12:13:55 2010 +0100
+++ b/web/js/utils.js	Tue Jan 19 01:39:32 2010 +0100
@@ -363,9 +363,9 @@
 function checkForChanges(f) {
 	var form = f;
 	
-	if (form == null) {
-		if(frames.name.indexOf('appFrame')==-1 && frames.name.indexOf('frameMenu')==-1) {
-			if(top.opener != null) { // is a pop-up window
+	if (form === null) {
+		if(frames.name.indexOf('appFrame') === -1 && frames.name.indexOf('frameMenu') === -1) {
+			if(top.opener !== null) { // is a pop-up window
 				form = top.opener.top.appFrame.document.forms[0];
 			}
 		}
@@ -374,13 +374,13 @@
 		}
 	}
 	
-	if(typeof form == 'undefined') {
+	if(typeof form === 'undefined') {
 		return true;
 	}
 	
 	var autosave = null;
-	if(frames.name.indexOf('appFrame')==-1 && frames.name.indexOf('frameMenu')==-1) {
-		if(top.opener != null) { // is a pop-up window
+	if(frames.name.indexOf('appFrame') === -1 && frames.name.indexOf('frameMenu') === -1) {
+		if(top.opener !== null) { // is a pop-up window
 		  autosave = top.opener.top.frameMenu.autosave;
 		}
 	}
@@ -388,8 +388,8 @@
 	  autosave = top.frameMenu.autosave;
 	}
 	
-	if(typeof autosave == 'undefined' || !autosave) { // 2.40 behavior		
-		if (inputValue(form.inpLastFieldChanged)!="") {
+	if(typeof autosave === 'undefined' || !autosave) { // 2.40 behavior		
+		if (inputValue(form.inpLastFieldChanged) !== "") {
 			if (!showJSMessage(26))
 				return false;
 		}
@@ -399,16 +399,35 @@
 		return true;
 	}
 	else {
-		if(typeof top.appFrame == 'undefined'){
+		if(typeof top.appFrame === 'undefined'){
 			return true;
-		}		
-		var promptConfirmation = typeof top.appFrame.confirmOnChanges == 'undefined' ? true : top.appFrame.confirmOnChanges;
-		var hasUserChanges = typeof top.appFrame.isUserChanges == 'undefined' ? false : top.appFrame.isUserChanges;
+		}
+
+		try {
+		  var promptConfirmation = typeof top.appFrame.confirmOnChanges === 'undefined' ? true : top.appFrame.confirmOnChanges;
+		} catch(e) {
+		  if(isDebugEnabled()) {
+            console.error("%o", e);
+		  }
+		}
+
+		try {
+		  var hasUserChanges = typeof top.appFrame.isUserChanges === 'undefined' ? false : top.appFrame.isUserChanges;
+		} catch(e) {
+		  if(isDebugEnabled()) {
+            console.error("%o", e);
+		  }
+		}
+
+        if(typeof promptConfirmation === 'undefined' || typeof hasUserChanges === 'undefined') { // Nothing to be done
+          return true;
+        }
+
 		if (form.inpLastFieldChanged && (hasUserChanges || isButtonClick || isTabClick)) { // if the inpLastFieldChanged exists and there is a user change
 			var autoSaveFlag = autosave;		
 			if (promptConfirmation && hasUserChanges) {
 				autoSaveFlag = showJSMessage(25);
-				if(typeof top.appFrame.confirmOnChanges != 'undefined' && autoSaveFlag) {
+				if(typeof top.appFrame.confirmOnChanges !== 'undefined' && autoSaveFlag) {
 					top.appFrame.confirmOnChanges = false;
 				}
 			}
@@ -510,7 +529,7 @@
  */
 function depurar_validate_wrapper(action, form, value) {
   // if new-style validate-function exists => call it
-  if (typeof validate == "function") {
+  if (typeof validate === "function") {
     return validate(action, form, value);
   } else {
     // call old-style depurar function
@@ -3179,6 +3198,7 @@
       obj.className = className.replace("LabelText","LabelTextReadOnly");
     if ((className.indexOf("TextBox_")!=-1)||(className.indexOf("TextArea_")!=-1)) {
       if (className.indexOf("readonly")==-1) changeClass(id,'readonly ', '');
+      disableFieldButton(getAssociatedFieldButton(obj, 'window'));
     }
   } else { //not readonly
     obj.className = obj.className.replace("ReadOnly","");
@@ -3199,6 +3219,9 @@
         obj.setAttribute("onChange",newOnChange_combo); 
       }
     }
+    if ((obj.className.indexOf("TextBox_")!=-1)||(obj.className.indexOf("TextArea_")!=-1)) {
+      enableFieldButton(getAssociatedFieldButton(obj, 'window'));
+    }
   }
   return true;
 }
--- a/web/js/windowKeyboard.js	Fri Jan 15 12:13:55 2010 +0100
+++ b/web/js/windowKeyboard.js	Tue Jan 19 01:39:32 2010 +0100
@@ -1076,10 +1076,14 @@
   }
 }
 
-function getAssociatedFieldButton(type) {
+function getAssociatedFieldButton(input, type) {
   var fieldButton = null;
   var success = true;
-  fieldButton = focusedWindowElement;
+  if (typeof input == 'undefined' || input == null) {
+    fieldButton = focusedWindowElement;
+  } else {
+    fieldButton = input;
+  }
   if (type=='window') {
     try {
       //Go to the TD parent
@@ -1131,7 +1135,7 @@
 
 function executeAssociatedFieldButton() {
   var fieldButton = null;
-  fieldButton = getAssociatedFieldButton('window');
+  fieldButton = getAssociatedFieldButton(null, 'window');
   if (fieldButton != null && fieldButton != false) {
     fieldButton.onclick();
     return true;